From 8abd49be00dba564fbda56384e348f7d4e9c02f8 Mon Sep 17 00:00:00 2001 From: Jing Ji Date: Tue, 5 Apr 2022 16:04:08 -0700 Subject: Update the PendingIntent to launch Settings on bg restriction alert Bug: 203105544 Bug: 227947723 Bug: 227615380 Test: Manual - trigger a bg restriction alert and tap on it. Change-Id: Iddfabb8b81a995b9f5839c88c34a0d453b733919 --- .../core/java/com/android/server/am/AppRestrictionController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/AppRestrictionController.java b/services/core/java/com/android/server/am/AppRestrictionController.java index 708bd1662a77..313bedb37164 100644 --- a/services/core/java/com/android/server/am/AppRestrictionController.java +++ b/services/core/java/com/android/server/am/AppRestrictionController.java @@ -2289,9 +2289,10 @@ public final class AppRestrictionController { void postRequestBgRestrictedIfNecessary(String packageName, int uid) { final Intent intent = new Intent(Settings.ACTION_VIEW_ADVANCED_POWER_USAGE_DETAIL); intent.setData(Uri.fromParts(PACKAGE_SCHEME, packageName, null)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(mContext, 0, - intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, null, + intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE, null, UserHandle.of(UserHandle.getUserId(uid))); Notification.Action[] actions = null; final boolean hasForegroundServices = @@ -2347,13 +2348,14 @@ public final class AppRestrictionController { intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); // Task manager runs in SystemUI, which is SYSTEM user only. pendingIntent = PendingIntent.getBroadcastAsUser(mContext, 0, - intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, + intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE, UserHandle.SYSTEM); } else { final Intent intent = new Intent(Settings.ACTION_VIEW_ADVANCED_POWER_USAGE_DETAIL); intent.setData(Uri.fromParts(PACKAGE_SCHEME, packageName, null)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pendingIntent = PendingIntent.getActivityAsUser(mContext, 0, - intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, + intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE, null, UserHandle.of(UserHandle.getUserId(uid))); } -- cgit v1.2.3-59-g8ed1b