Update app usage page power summary

- Present empty string when this app consumed power but no usage time,
 usually they are some system components

Bug: 197749108
Test: make -j64 RunSettingsRoboTest
Change-Id: I1e88babb30c871748fa1f5fc23c7b4d834e384fd
This commit is contained in:
Wesley.CW Wang
2021-10-21 15:54:57 +08:00
parent 541f0e447f
commit 23a5fb5e74
3 changed files with 26 additions and 7 deletions

View File

@@ -326,10 +326,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
}
if (mEnableTriState) {
final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
final String slotTime = bundle.getString(EXTRA_SLOT_TIME, null);
controller.setSummary(getAppActiveTime(foregroundTimeMs, backgroundTimeMs, slotTime));
controller.setSummary(getAppActiveTime(bundle));
}
controller.done(context, true /* rebindActions */);
@@ -493,16 +490,21 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
mOptimizationMode = mBatteryOptimizeUtils.getAppOptimizationMode();
}
private CharSequence getAppActiveTime(
long foregroundTimeMs, long backgroundTimeMs, String slotTime) {
private CharSequence getAppActiveTime(Bundle bundle) {
final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
final int consumedPower = bundle.getInt(EXTRA_POWER_USAGE_AMOUNT);
final String slotTime = bundle.getString(EXTRA_SLOT_TIME, null);
final long totalTimeMs = foregroundTimeMs + backgroundTimeMs;
final CharSequence usageTimeSummary;
final PowerUsageFeatureProvider powerFeatureProvider =
FeatureFactory.getFactory(getContext()).getPowerUsageFeatureProvider(getContext());
if (totalTimeMs == 0) {
final int batteryWithoutUsageTime = consumedPower > 0
? R.string.battery_usage_without_time : R.string.battery_not_usage_24hr;
usageTimeSummary = getText(powerFeatureProvider.isChartGraphEnabled(getContext())
? R.string.battery_not_usage_24hr : R.string.battery_not_usage);
? batteryWithoutUsageTime : R.string.battery_not_usage);
} else if (slotTime == null) {
// Shows summary text with past 24 hr or full charge if slot time is null.
usageTimeSummary = powerFeatureProvider.isChartGraphEnabled(getContext())