Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52672ca3 authored by mxyyiyi's avatar mxyyiyi
Browse files

Fix summary for system components which 30 sec <= usage time < 1 min.

- formatElapsedTimeWithoutComma(withSecords = false,) will round up minutes by adding 30 seconds.
https://screenshot.googleplex.com/8HrDpLi8FX8tjJy

Bug: 321265878
Test: Manual
Change-Id: I779bd7c33bbb3aefa0a88f6ba42d047259bc50cc
parent 077158e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -670,7 +670,7 @@ public class BatteryUtils {
            long timeInMs,
            final int lessThanOneMinuteResId,
            final int normalResId) {
        if (timeInMs < DateUtils.MINUTE_IN_MILLIS) {
        if (timeInMs <= DateUtils.MINUTE_IN_MILLIS / 2) {
            return context.getString(lessThanOneMinuteResId);
        }
        final CharSequence timeSequence =
+5 −4
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public final class BatteryUsageBreakdownControllerTest {
    private static final String PREF_KEY = "pref_key";
    private static final String PREF_KEY2 = "pref_key2";
    private static final String PREF_SUMMARY = "fake preference summary";
    private static final long TIME_LESS_THAN_HALF_MINUTE  = DateUtils.MINUTE_IN_MILLIS / 2  - 1;

    @Mock private InstrumentedPreferenceFragment mFragment;
    @Mock private SettingsActivity mSettingsActivity;
@@ -332,7 +333,7 @@ public final class BatteryUsageBreakdownControllerTest {
                createBatteryDiffEntry(
                        /* isSystem= */ true,
                        /* screenOnTimeInMs= */ 0,
                        /* foregroundUsageTimeInMs= */ DateUtils.MINUTE_IN_MILLIS - 1,
                        /* foregroundUsageTimeInMs= */ TIME_LESS_THAN_HALF_MINUTE,
                        /* foregroundServiceUsageTimeInMs= */ 0,
                        /* backgroundUsageTimeInMs= */ 0));
        assertThat(pref.getSummary().toString()).isEqualTo("Total: less than a minute");
@@ -427,10 +428,10 @@ public final class BatteryUsageBreakdownControllerTest {
                pref,
                createBatteryDiffEntry(
                        /* isSystem= */ false,
                        /* screenOnTimeInMs= */ DateUtils.MINUTE_IN_MILLIS - 1,
                        /* foregroundUsageTimeInMs= */ DateUtils.MINUTE_IN_MILLIS - 1,
                        /* screenOnTimeInMs= */ TIME_LESS_THAN_HALF_MINUTE,
                        /* foregroundUsageTimeInMs= */ TIME_LESS_THAN_HALF_MINUTE,
                        /* foregroundServiceUsageTimeInMs= */ 0,
                        /* backgroundUsageTimeInMs= */ DateUtils.MINUTE_IN_MILLIS - 1));
                        /* backgroundUsageTimeInMs= */ TIME_LESS_THAN_HALF_MINUTE));
        assertThat(pref.getSummary().toString())
                .isEqualTo("Screen time: less than a minute\nBackground: less than a minute");
    }