From 9ba128c089d38163e06f0b11889ece4425435394 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Sun, 5 Mar 2023 10:12:18 +0000 Subject: [PATCH] Apply delivery group policies to CLOSE_SYSTEM_DIALOG broadcast. - The "set-defer-until-active" policy is applied so that the broadcast targeted to apps in the Cached state is deferred until they come out of that state. - The "deliver-most-recent" policy is applied so that if there are already pending broadcasts waiting to be delivered when a new broadcast is sent, the old ones are discarded. Bug: 271950524 Test: TH Change-Id: Id3bd218e9b54e93ca57607602730836fd12affc8 --- .../com/android/server/am/ActivityManagerService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index af9b2beb998aa..cf169f044aa02 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -18199,8 +18199,14 @@ public class ActivityManagerService extends IActivityManager.Stub intent.putExtra("reason", reason); } + final BroadcastOptions options = new BroadcastOptions() + .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT) + .setDeferUntilActive(true); + if (reason != null) { + options.setDeliveryGroupMatchingKey(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, reason); + } broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null, - null, null, OP_NONE, null, false, false, -1, SYSTEM_UID, + null, null, OP_NONE, options.toBundle(), false, false, -1, SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL); } }