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

Commit d1d8aa66 authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

Persist Standby Buckets after System defaults set

Also repair defaults if persisted file is missing on boot.

Fixes: 123206562
Test: manual ("adb shell reboot" within 20 min of a fresh wipe
              "adb shell dumpsys usagestats"
	      System apps bucket levels equal 10)

Change-Id: I0403099c899d181ef6206cc9f5516c25213edc9c
parent 1512e805
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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 {
+8 −1
Original line number Diff line number Diff line
@@ -372,7 +372,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);
            }

@@ -1411,6 +1416,8 @@ public class AppStandbyController {
                            elapsedRealtime + mSystemUpdateUsageTimeoutMillis);
                }
            }
            // Immediately persist defaults to disk
            mAppIdleHistory.writeAppIdleTimes(userId);
        }
    }