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

This commit is contained in:
TreeHugger Robot
2023-01-31 11:44:39 +00:00
committed by Android (Google) Code Review
4 changed files with 236 additions and 44 deletions

View File

@@ -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,