Merge "Persist Standby Buckets after System defaults set"

This commit is contained in:
Michael Wachenschwanz
2019-03-07 02:07:33 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 1 deletions

View File

@@ -508,6 +508,16 @@ public class AppIdleHistory {
Integer.toString(userId)), APP_IDLE_FILENAME);
}
/**
* Check if App Idle File exists on disk
* @param userId
* @return true if file exists
*/
public boolean userFileExists(int userId) {
return getUserFile(userId).exists();
}
private void readAppIdleTimes(int userId, ArrayMap<String, AppUsageHistory> userHistory) {
FileInputStream fis = null;
try {

View File

@@ -377,7 +377,12 @@ public class AppStandbyController {
mSystemServicesReady = true;
if (mPendingInitializeDefaults) {
boolean userFileExists;
synchronized (mAppIdleLock) {
userFileExists = mAppIdleHistory.userFileExists(UserHandle.USER_SYSTEM);
}
if (mPendingInitializeDefaults || !userFileExists) {
initializeDefaultsForSystemApps(UserHandle.USER_SYSTEM);
}
@@ -1435,6 +1440,8 @@ public class AppStandbyController {
elapsedRealtime + mSystemUpdateUsageTimeoutMillis);
}
}
// Immediately persist defaults to disk
mAppIdleHistory.writeAppIdleTimes(userId);
}
}