Transition HighUsageDetector to BatteryUsageStats API

Bug: 173745486
Test: make RunSettingsRoboTests
Test: male RunSettingsGoogleRoboTests

Change-Id: Ie8f90a67e4dd16fa67cf4f44a3678a789b3da18a
This commit is contained in:
Dmitri Plotnikov
2021-03-13 20:31:17 -08:00
parent b72d0ee651
commit 8f6c946c82
9 changed files with 84 additions and 205 deletions

View File

@@ -17,10 +17,10 @@
package com.android.settings.fuelgauge.batterytip;
import android.content.Context;
import android.os.BatteryUsageStats;
import androidx.annotation.VisibleForTesting;
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.detectors.BatteryDefenderDetector;
@@ -48,13 +48,13 @@ public class BatteryTipLoader extends AsyncLoaderCompat<List<BatteryTip>> {
private static final boolean USE_FAKE_DATA = false;
private BatteryStatsHelper mBatteryStatsHelper;
private BatteryUsageStats mBatteryUsageStats;
@VisibleForTesting
BatteryUtils mBatteryUtils;
public BatteryTipLoader(Context context, BatteryStatsHelper batteryStatsHelper) {
public BatteryTipLoader(Context context, BatteryUsageStats batteryUsageStats) {
super(context);
mBatteryStatsHelper = batteryStatsHelper;
mBatteryUsageStats = batteryUsageStats;
mBatteryUtils = BatteryUtils.getInstance(context);
}
@@ -69,7 +69,7 @@ public class BatteryTipLoader extends AsyncLoaderCompat<List<BatteryTip>> {
final Context context = getContext();
tips.add(new LowBatteryDetector(context, policy, batteryInfo).detect());
tips.add(new HighUsageDetector(context, policy, mBatteryStatsHelper, batteryInfo).detect());
tips.add(new HighUsageDetector(context, policy, mBatteryUsageStats, batteryInfo).detect());
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
tips.add(new EarlyWarningDetector(policy, context).detect());
tips.add(new BatteryDefenderDetector(batteryInfo).detect());