Add cache strategy for getUsageSource().

Cache usage source into SharedPreferences when phone is booting to avoid
calling it too frequently.
It should be safe because the usage source can only change on reboot.

Bug: 293366011
Test: make RunSettingsRoboTests
Change-Id: I35c07539d294737c5764b03b746cfb39f4ce008d
This commit is contained in:
Kuan Wang
2023-07-28 13:31:31 +08:00
parent 98df5bcde2
commit 64177774e2
10 changed files with 190 additions and 85 deletions

View File

@@ -397,8 +397,8 @@ public class DataProcessManager {
}
// Generates the indexed AppUsagePeriod list data for each corresponding time slot for
// further use.
mAppUsagePeriodMap = DataProcessor.generateAppUsagePeriodMap(mRawStartTimestamp,
mHourlyBatteryLevelsPerDay, mAppUsageEventList, mBatteryEventList);
mAppUsagePeriodMap = DataProcessor.generateAppUsagePeriodMap(
mContext, mHourlyBatteryLevelsPerDay, mAppUsageEventList, mBatteryEventList);
}
private void tryToGenerateFinalDataAndApplyCallback() {