1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.settings.fuelgauge;
17 
18 import android.content.Context;
19 
20 import com.android.settings.overlay.FeatureFactory;
21 import com.android.settingslib.utils.AsyncLoaderCompat;
22 
23 import java.util.Map;
24 
25 /** Loader that can be used to load battery history information. */
26 public class BatteryHistoryLoader
27         extends AsyncLoaderCompat<Map<Long, Map<String, BatteryHistEntry>>> {
28     private static final String TAG = "BatteryHistoryLoader";
29 
30     private final Context mContext;
31 
BatteryHistoryLoader(Context context)32     public BatteryHistoryLoader(Context context) {
33         super(context);
34         mContext = context;
35     }
36 
37     @Override
onDiscardResult(Map<Long, Map<String, BatteryHistEntry>> result)38     protected void onDiscardResult(Map<Long, Map<String, BatteryHistEntry>> result) {
39     }
40 
41     @Override
loadInBackground()42     public Map<Long, Map<String, BatteryHistEntry>> loadInBackground() {
43         final PowerUsageFeatureProvider powerUsageFeatureProvider =
44             FeatureFactory.getFactory(mContext).getPowerUsageFeatureProvider(mContext);
45         return powerUsageFeatureProvider.getBatteryHistory(mContext);
46     }
47 }
48