From 250f9f9099396bac3c52b4d8030ef949debfd7fa Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Thu, 10 Mar 2022 20:42:49 +0000 Subject: [PATCH] Only note restrictions attempts for RESTRICTED bucket. We don't want to put an app in the RESTRICTED bucket too soon after a user has used the app. If the system attempts to restrict the app (probably through the restrictApp() API), and the user has recently used the app, then we'll note the restriction attempt and delay putting the app into the bucket until our min delay time has passed. Now, we make sure to only note the restriction attempt when the bucket is the RESTRICTED bucket. Bug: 223863858 Test: atest FrameworksMockingServicesTests:AppStandbyControllerTests Change-Id: Iaf6647bfd8a72206f2b80df8b21d2446f4eeb291 --- .../java/com/android/server/usage/AppStandbyController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java index 849354bd1d972..8c54fd1ed0764 100644 --- a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +++ b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java @@ -1573,8 +1573,10 @@ public class AppStandbyController (reason & REASON_MAIN_MASK) == REASON_MAIN_FORCED_BY_SYSTEM; if (app.currentBucket == newBucket && wasForcedBySystem && isForcedBySystem) { - mAppIdleHistory - .noteRestrictionAttempt(packageName, userId, elapsedRealtime, reason); + if (newBucket == STANDBY_BUCKET_RESTRICTED) { + mAppIdleHistory + .noteRestrictionAttempt(packageName, userId, elapsedRealtime, reason); + } // Keep track of all restricting reasons reason = REASON_MAIN_FORCED_BY_SYSTEM | (app.bucketingReason & REASON_SUB_MASK)