Provide allow-list to recipient of voicemail intents.

This enables an app receiving the intent to launch a background activity
to perform more time consuming (but time sensitive) voicemail related
work.

Test: Manual test; verified that when new VVM broadcast is sent that the
broadcast options are set to allow-list the recipient for 10sec.
Bug: 173155475

Merged-In: I65823691d67e3765cb565598714abb11d3760989
Change-Id: I65823691d67e3765cb565598714abb11d3760989
(cherry picked from commit 93badfa8ce448e52be211ac083dedc5f0f7ca653)
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index c2dece5..1be7273 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -19,6 +19,7 @@
 import static android.Manifest.permission.READ_PHONE_STATE;
 
 import android.annotation.Nullable;
+import android.app.BroadcastOptions;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
@@ -106,6 +107,12 @@
 
     private static final String ACTION_MOBILE_NETWORK_LIST = "android.settings.MOBILE_NETWORK_LIST";
 
+    /**
+     * Grant recipients of new voicemail broadcasts a 10sec allowlist so they can start a background
+     * service to do VVM processing.
+     */
+    private final long VOICEMAIL_ALLOW_LIST_DURATION_MILLIS = 10000L;
+
     /** The singleton NotificationMgr instance. */
     private static NotificationMgr sInstance;
 
@@ -470,7 +477,10 @@
                             pendingIntent);
                 }
             }
-            mContext.sendBroadcastAsUser(intent, userHandle, READ_PHONE_STATE);
+
+            BroadcastOptions bopts = BroadcastOptions.makeBasic();
+            bopts.setTemporaryAppWhitelistDuration(VOICEMAIL_ALLOW_LIST_DURATION_MILLIS);
+            mContext.sendBroadcastAsUser(intent, userHandle, READ_PHONE_STATE, bopts.toBundle());
             return true;
         }