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
AOSP: The new broadcasts are not available in AOSP
Change-Id: I5e624b271cfb0401e247fd43f429efb45bce6a3b
diff --git a/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java b/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java
index e1f2d08..0be90e0 100644
--- a/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java
+++ b/src/com/android/server/telecom/TelecomBroadcastIntentProcessor.java
@@ -16,10 +16,12 @@
package com.android.server.telecom;
+import android.app.BroadcastOptions;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.Bundle;
import android.os.UserHandle;
import android.telecom.Log;
import android.widget.Toast;
@@ -247,8 +249,14 @@
* Closes open system dialogs and the notification shade.
*/
private void closeSystemDialogs(Context context) {
- Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
- context.sendBroadcastAsUser(intent, UserHandle.ALL);
+ Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
+ .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ Bundle options = BroadcastOptions.makeBasic()
+ .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
+ .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
+ .toBundle();
+ context.sendBroadcastAsUser(intent, UserHandle.ALL, null /* receiverPermission */,
+ options);
}
private void sendSmsIntent(Intent intent, UserHandle userHandle) {