• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.batteryusage;
17 
18 import android.content.Context;
19 
20 import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
21 import com.android.settings.overlay.FeatureFactory;
22 import com.android.settingslib.utils.AsyncLoaderCompat;
23 
24 import java.util.Map;
25 
26 /** Loader that can be used to load battery history information. */
27 public class BatteryHistoryLoader
28         extends AsyncLoaderCompat<Map<Long, Map<String, BatteryHistEntry>>> {
29     private static final String TAG = "BatteryHistoryLoader";
30 
31     private final Context mContext;
32 
BatteryHistoryLoader(Context context)33     public BatteryHistoryLoader(Context context) {
34         super(context);
35         mContext = context;
36     }
37 
38     @Override
onDiscardResult(Map<Long, Map<String, BatteryHistEntry>> result)39     protected void onDiscardResult(Map<Long, Map<String, BatteryHistEntry>> result) {
40     }
41 
42     @Override
loadInBackground()43     public Map<Long, Map<String, BatteryHistEntry>> loadInBackground() {
44         final PowerUsageFeatureProvider powerUsageFeatureProvider =
45                 FeatureFactory.getFactory(mContext).getPowerUsageFeatureProvider(mContext);
46         return powerUsageFeatureProvider.getBatteryHistorySinceLastFullCharge(mContext);
47     }
48 }
49