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

Commit 1b73b6c6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix battery usage chart error when daylight saving."

parents 2646bc2f d72ff28a
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -99,10 +99,10 @@ public final class DataProcessor {
    static boolean sDebug = false;

    @VisibleForTesting
    static long sFakeCurrentTimeMillis = 0;
    static long sTestCurrentTimeMillis = 0;

    @VisibleForTesting
    static Set<String> sFakeSystemAppsSet;
    static Set<String> sTestSystemAppsSet;

    @VisibleForTesting
    static IUsageStatsManager sUsageStatsManager =
@@ -539,7 +539,7 @@ public final class DataProcessor {
        }
        while (nextDay < endTime) {
            dailyTimestampList.add(nextDay);
            nextDay += DateUtils.DAY_IN_MILLIS;
            nextDay = getTimestampOfNextDay(nextDay);
        }
        final long lastDailyTimestamp = dailyTimestampList.get(dailyTimestampList.size() - 1);
        // Only if the timestamp diff in the last day is bigger than MIN_TIME_SLOT, add the
@@ -1900,12 +1900,12 @@ public final class DataProcessor {
    }

    private static Set<String> getSystemAppsSet(Context context) {
        return sFakeSystemAppsSet != null ? sFakeSystemAppsSet
        return sTestSystemAppsSet != null ? sTestSystemAppsSet
                : AppListRepositoryUtil.getSystemPackageNames(context, context.getUserId(), false);
    }

    private static long getCurrentTimeMillis() {
        return sFakeCurrentTimeMillis > 0 ? sFakeCurrentTimeMillis : System.currentTimeMillis();
        return sTestCurrentTimeMillis > 0 ? sTestCurrentTimeMillis : System.currentTimeMillis();
    }

    private static void log(Context context, final String content, final long timestamp,
+2 −2
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public final class BatteryChartPreferenceControllerTest {
        Locale.setDefault(new Locale("en_US"));
        org.robolectric.shadows.ShadowSettings.set24HourTimeFormat(false);
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        DataProcessor.sFakeSystemAppsSet = Set.of();
        DataProcessor.sTestSystemAppsSet = Set.of();
        mFeatureFactory = FakeFeatureFactory.setupForTest();
        mContext = spy(RuntimeEnvironment.application);
        doReturn(mContext).when(mContext).getApplicationContext();
@@ -405,7 +405,7 @@ public final class BatteryChartPreferenceControllerTest {
            entryMap.put("fake_entry_key" + index, entry);
            batteryHistoryMap.put(generateTimestamp(index), entryMap);
        }
        DataProcessor.sFakeCurrentTimeMillis =
        DataProcessor.sTestCurrentTimeMillis =
                generateTimestamp(numOfHours - 1) + DateUtils.MINUTE_IN_MILLIS;
        return batteryHistoryMap;
    }
+2 −2
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ public final class DataProcessManagerTest {
        final int[] levels = {100, 99, 98};
        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap =
                createHistoryMap(timestamps, levels);
        DataProcessor.sFakeCurrentTimeMillis = timestamps[timestamps.length - 1];
        DataProcessor.sTestCurrentTimeMillis = timestamps[timestamps.length - 1];

        assertThat(DataProcessManager.getBatteryLevelData(
                mContext, /*handler=*/ null, batteryHistoryMap, /*asyncResponseDelegate=*/ null))
@@ -322,7 +322,7 @@ public final class DataProcessManagerTest {
        final int[] levels = {100, 99};
        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap =
                createHistoryMap(timestamps, levels);
        DataProcessor.sFakeCurrentTimeMillis = timestamps[timestamps.length - 1];
        DataProcessor.sTestCurrentTimeMillis = timestamps[timestamps.length - 1];

        final BatteryLevelData resultData =
                DataProcessManager.getBatteryLevelData(
+227 −35

File changed.

Preview size limit exceeded, changes collapsed.