Loading services/usage/java/com/android/server/usage/AppIdleHistory.java +13 −1 Original line number Diff line number Diff line Loading @@ -340,15 +340,27 @@ public class AppIdleHistory { public void setAppStandbyBucket(String packageName, int userId, long elapsedRealtime, int bucket, int reason) { setAppStandbyBucket(packageName, userId, elapsedRealtime, bucket, reason, false); } public void setAppStandbyBucket(String packageName, int userId, long elapsedRealtime, int bucket, int reason, boolean resetTimeout) { ArrayMap<String, AppUsageHistory> userHistory = getUserHistory(userId); AppUsageHistory appUsageHistory = getPackageHistory(userHistory, packageName, elapsedRealtime, true); appUsageHistory.currentBucket = bucket; appUsageHistory.bucketingReason = reason; final long elapsed = getElapsedTime(elapsedRealtime); if ((reason & REASON_MAIN_MASK) == REASON_MAIN_PREDICTED) { appUsageHistory.lastPredictedTime = getElapsedTime(elapsedRealtime); appUsageHistory.lastPredictedTime = elapsed; appUsageHistory.lastPredictedBucket = bucket; } if (resetTimeout) { appUsageHistory.bucketActiveTimeoutTime = elapsed; appUsageHistory.bucketWorkingSetTimeoutTime = elapsed; } if (DEBUG) { Slog.d(TAG, "Moved " + packageName + " to bucket=" + appUsageHistory.currentBucket + ", reason=0x0" + Integer.toHexString(appUsageHistory.bucketingReason)); Loading services/usage/java/com/android/server/usage/AppStandbyController.java +9 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,9 @@ import java.util.concurrent.CountDownLatch; /** * Manages the standby state of an app, listening to various events. * * Unit test: atest ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java */ public class AppStandbyController { Loading Loading @@ -1106,6 +1109,11 @@ public class AppStandbyController { void setAppStandbyBucket(String packageName, int userId, @StandbyBuckets int newBucket, int reason, long elapsedRealtime) { setAppStandbyBucket(packageName, userId, newBucket, reason, elapsedRealtime, false); } void setAppStandbyBucket(String packageName, int userId, @StandbyBuckets int newBucket, int reason, long elapsedRealtime, boolean resetTimeout) { synchronized (mAppIdleLock) { AppIdleHistory.AppUsageHistory app = mAppIdleHistory.getAppUsageHistory(packageName, userId, elapsedRealtime); Loading Loading @@ -1155,7 +1163,7 @@ public class AppStandbyController { } mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime, newBucket, reason); reason, resetTimeout); } maybeInformListeners(packageName, userId, elapsedRealtime, newBucket, reason, false); } Loading services/usage/java/com/android/server/usage/UsageStatsService.java +3 −2 Original line number Diff line number Diff line Loading @@ -900,6 +900,7 @@ public class UsageStatsService extends SystemService implements } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } final boolean shellCaller = callingUid == 0 || callingUid == Process.SHELL_UID; final boolean systemCaller = UserHandle.isCore(callingUid); final int reason = systemCaller ? UsageStatsManager.REASON_MAIN_FORCED Loading @@ -918,7 +919,7 @@ public class UsageStatsService extends SystemService implements + ")"); } mAppStandby.setAppStandbyBucket(packageName, userId, bucket, reason, SystemClock.elapsedRealtime()); SystemClock.elapsedRealtime(), shellCaller); } finally { Binder.restoreCallingIdentity(token); } Loading Loading @@ -985,7 +986,7 @@ public class UsageStatsService extends SystemService implements throw new IllegalArgumentException("Cannot set your own standby bucket"); } mAppStandby.setAppStandbyBucket(packageName, userId, bucket, reason, elapsedRealtime); elapsedRealtime, shellCaller); } } finally { Binder.restoreCallingIdentity(token); Loading Loading
services/usage/java/com/android/server/usage/AppIdleHistory.java +13 −1 Original line number Diff line number Diff line Loading @@ -340,15 +340,27 @@ public class AppIdleHistory { public void setAppStandbyBucket(String packageName, int userId, long elapsedRealtime, int bucket, int reason) { setAppStandbyBucket(packageName, userId, elapsedRealtime, bucket, reason, false); } public void setAppStandbyBucket(String packageName, int userId, long elapsedRealtime, int bucket, int reason, boolean resetTimeout) { ArrayMap<String, AppUsageHistory> userHistory = getUserHistory(userId); AppUsageHistory appUsageHistory = getPackageHistory(userHistory, packageName, elapsedRealtime, true); appUsageHistory.currentBucket = bucket; appUsageHistory.bucketingReason = reason; final long elapsed = getElapsedTime(elapsedRealtime); if ((reason & REASON_MAIN_MASK) == REASON_MAIN_PREDICTED) { appUsageHistory.lastPredictedTime = getElapsedTime(elapsedRealtime); appUsageHistory.lastPredictedTime = elapsed; appUsageHistory.lastPredictedBucket = bucket; } if (resetTimeout) { appUsageHistory.bucketActiveTimeoutTime = elapsed; appUsageHistory.bucketWorkingSetTimeoutTime = elapsed; } if (DEBUG) { Slog.d(TAG, "Moved " + packageName + " to bucket=" + appUsageHistory.currentBucket + ", reason=0x0" + Integer.toHexString(appUsageHistory.bucketingReason)); Loading
services/usage/java/com/android/server/usage/AppStandbyController.java +9 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,9 @@ import java.util.concurrent.CountDownLatch; /** * Manages the standby state of an app, listening to various events. * * Unit test: atest ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java */ public class AppStandbyController { Loading Loading @@ -1106,6 +1109,11 @@ public class AppStandbyController { void setAppStandbyBucket(String packageName, int userId, @StandbyBuckets int newBucket, int reason, long elapsedRealtime) { setAppStandbyBucket(packageName, userId, newBucket, reason, elapsedRealtime, false); } void setAppStandbyBucket(String packageName, int userId, @StandbyBuckets int newBucket, int reason, long elapsedRealtime, boolean resetTimeout) { synchronized (mAppIdleLock) { AppIdleHistory.AppUsageHistory app = mAppIdleHistory.getAppUsageHistory(packageName, userId, elapsedRealtime); Loading Loading @@ -1155,7 +1163,7 @@ public class AppStandbyController { } mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime, newBucket, reason); reason, resetTimeout); } maybeInformListeners(packageName, userId, elapsedRealtime, newBucket, reason, false); } Loading
services/usage/java/com/android/server/usage/UsageStatsService.java +3 −2 Original line number Diff line number Diff line Loading @@ -900,6 +900,7 @@ public class UsageStatsService extends SystemService implements } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } final boolean shellCaller = callingUid == 0 || callingUid == Process.SHELL_UID; final boolean systemCaller = UserHandle.isCore(callingUid); final int reason = systemCaller ? UsageStatsManager.REASON_MAIN_FORCED Loading @@ -918,7 +919,7 @@ public class UsageStatsService extends SystemService implements + ")"); } mAppStandby.setAppStandbyBucket(packageName, userId, bucket, reason, SystemClock.elapsedRealtime()); SystemClock.elapsedRealtime(), shellCaller); } finally { Binder.restoreCallingIdentity(token); } Loading Loading @@ -985,7 +986,7 @@ public class UsageStatsService extends SystemService implements throw new IllegalArgumentException("Cannot set your own standby bucket"); } mAppStandby.setAppStandbyBucket(packageName, userId, bucket, reason, elapsedRealtime); elapsedRealtime, shellCaller); } } finally { Binder.restoreCallingIdentity(token); Loading