Merge "Update app usage page power summary" into sc-v2-dev am: 8e97bdd76c
am: 054f3b5199
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16091765 Change-Id: Ic7bf43d79304b740b5b6cf2a148b317860ea4869
This commit is contained in:
@@ -6568,6 +6568,8 @@
|
|||||||
<string name="battery_not_usage">No usage from last full charge</string>
|
<string name="battery_not_usage">No usage from last full charge</string>
|
||||||
<!-- Description for no any battery usage for past 24 hr [CHAR LIMIT=120] -->
|
<!-- Description for no any battery usage for past 24 hr [CHAR LIMIT=120] -->
|
||||||
<string name="battery_not_usage_24hr">No usage for past 24 hr</string>
|
<string name="battery_not_usage_24hr">No usage for past 24 hr</string>
|
||||||
|
<!-- Description for no usage time but have battery usage [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_usage_without_time"></string>
|
||||||
|
|
||||||
<!-- Graph subtext displayed to user when enhanced battery estimate is being used [CHAR LIMIT=120] -->
|
<!-- Graph subtext displayed to user when enhanced battery estimate is being used [CHAR LIMIT=120] -->
|
||||||
<string name="advanced_battery_graph_subtext">Battery left estimate is based on your device usage</string>
|
<string name="advanced_battery_graph_subtext">Battery left estimate is based on your device usage</string>
|
||||||
|
@@ -327,10 +327,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mEnableTriState) {
|
if (mEnableTriState) {
|
||||||
final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
|
controller.setSummary(getAppActiveTime(bundle));
|
||||||
final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
|
|
||||||
final String slotTime = bundle.getString(EXTRA_SLOT_TIME, null);
|
|
||||||
controller.setSummary(getAppActiveTime(foregroundTimeMs, backgroundTimeMs, slotTime));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.done(context, true /* rebindActions */);
|
controller.done(context, true /* rebindActions */);
|
||||||
@@ -494,16 +491,21 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
|||||||
mOptimizationMode = mBatteryOptimizeUtils.getAppOptimizationMode();
|
mOptimizationMode = mBatteryOptimizeUtils.getAppOptimizationMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence getAppActiveTime(
|
private CharSequence getAppActiveTime(Bundle bundle) {
|
||||||
long foregroundTimeMs, long backgroundTimeMs, String slotTime) {
|
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 long totalTimeMs = foregroundTimeMs + backgroundTimeMs;
|
||||||
final CharSequence usageTimeSummary;
|
final CharSequence usageTimeSummary;
|
||||||
final PowerUsageFeatureProvider powerFeatureProvider =
|
final PowerUsageFeatureProvider powerFeatureProvider =
|
||||||
FeatureFactory.getFactory(getContext()).getPowerUsageFeatureProvider(getContext());
|
FeatureFactory.getFactory(getContext()).getPowerUsageFeatureProvider(getContext());
|
||||||
|
|
||||||
if (totalTimeMs == 0) {
|
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())
|
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) {
|
} else if (slotTime == null) {
|
||||||
// Shows summary text with past 24 hr or full charge if slot time is null.
|
// Shows summary text with past 24 hr or full charge if slot time is null.
|
||||||
usageTimeSummary = powerFeatureProvider.isChartGraphEnabled(getContext())
|
usageTimeSummary = powerFeatureProvider.isChartGraphEnabled(getContext())
|
||||||
|
@@ -437,6 +437,21 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
.isEqualTo("No usage for past 24 hr");
|
.isEqualTo("No usage for past 24 hr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_noUsageTimeButConsumedPower_hasEmptySummary() {
|
||||||
|
Bundle bundle = new Bundle(3);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
|
||||||
|
bundle.putInt(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_AMOUNT, /* value */ 10);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString()).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInitHeader_backgroundTwoMinForegroundZero_hasCorrectSummary() {
|
public void testInitHeader_backgroundTwoMinForegroundZero_hasCorrectSummary() {
|
||||||
final long backgroundTimeTwoMinutes = 120000;
|
final long backgroundTimeTwoMinutes = 120000;
|
||||||
|
Reference in New Issue
Block a user