Add dialog for summary tip

Also change SummaryTip to store the time data, which is used
in the dialog. If "Full last charge" time is available, show
normal message otherwise show message without it.

Bug: 72997971
Test: RunSettingsRoboTests
Change-Id: I4ce94f0935465a18275edb13e3be343313427c3b
This commit is contained in:
jackqdyulei
2018-02-28 11:21:39 -08:00
committed by Lei Yu
parent f11976d817
commit ede87ce19f
10 changed files with 171 additions and 16 deletions

View File

@@ -22,6 +22,7 @@ import android.support.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.Estimate;
import com.android.settings.fuelgauge.batterytip.detectors.EarlyWarningDetector;
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
@@ -70,7 +71,7 @@ public class BatteryTipLoader extends AsyncLoader<List<BatteryTip>> {
tips.add(new HighUsageDetector(context, policy, mBatteryStatsHelper).detect());
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
tips.add(new EarlyWarningDetector(policy, context).detect());
tips.add(new SummaryDetector(policy).detect());
tips.add(new SummaryDetector(policy, batteryInfo.averageTimeToDischarge).detect());
tips.add(new RestrictAppDetector(context, policy).detect());
Collections.sort(tips);
@@ -83,7 +84,8 @@ public class BatteryTipLoader extends AsyncLoader<List<BatteryTip>> {
private List<BatteryTip> getFakeData() {
final List<BatteryTip> tips = new ArrayList<>();
tips.add(new SummaryTip(BatteryTip.StateType.NEW));
tips.add(new SummaryTip(BatteryTip.StateType.NEW,
Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW));
return tips;