From 71fc7a5ce1707e8cc6e05ef16d8cce7a65f6a6e5 Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Tue, 22 Feb 2022 20:15:30 +0000 Subject: [PATCH] Stop showing RESTRICTED toast for new restriction. The RESTRICTED bucket isn't clear from the notification restriction option, so it'll be surprising for users to see the toast if they ask the system to restrict the app. Don't show the Toast if the user tries to restrict an app via the system's posted notification. Bug: 217964313 Bug: 220897723 Test: Android builds Change-Id: Ia86f5d6aa9ca4778395dde2834b2dd30cfc123a3 --- .../com/android/server/usage/AppStandbyController.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 b843dcaaf680b..cae6cdcf8f1fe 100644 --- a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +++ b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java @@ -25,6 +25,7 @@ import static android.app.usage.UsageStatsManager.REASON_MAIN_TIMEOUT; import static android.app.usage.UsageStatsManager.REASON_MAIN_USAGE; import static android.app.usage.UsageStatsManager.REASON_SUB_DEFAULT_APP_UPDATE; import static android.app.usage.UsageStatsManager.REASON_SUB_FORCED_SYSTEM_FLAG_BUGGY; +import static android.app.usage.UsageStatsManager.REASON_SUB_FORCED_USER_FLAG_INTERACTION; import static android.app.usage.UsageStatsManager.REASON_SUB_MASK; import static android.app.usage.UsageStatsManager.REASON_SUB_PREDICTED_RESTORED; import static android.app.usage.UsageStatsManager.REASON_SUB_USAGE_ACTIVE_TIMEOUT; @@ -1581,7 +1582,11 @@ public class AppStandbyController // Only user force can bypass the delay restriction. If the user forced the // app into the RESTRICTED bucket, then a toast confirming the action // shouldn't be surprising. - if (Build.IS_DEBUGGABLE) { + // Exclude REASON_SUB_FORCED_USER_FLAG_INTERACTION since the RESTRICTED bucket + // isn't directly visible in that flow. + if (Build.IS_DEBUGGABLE + && (reason & REASON_SUB_MASK) + != REASON_SUB_FORCED_USER_FLAG_INTERACTION) { Toast.makeText(mContext, // Since AppStandbyController sits low in the lock hierarchy, // make sure not to call out with the lock held.