diff options
author | Tyler Gunn <tgunn@google.com> | 2020-12-09 09:57:51 -0800 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2020-12-09 09:57:51 -0800 |
commit | 9f48bf2c8b3b80ac3ed1c4ef6350df25beab05b3 (patch) | |
tree | 4c48ddacbedd6c1defe430a47d4a1184dda3118a /src | |
parent | b8d130094648c4beff22656b60888072d8d984fe (diff) | |
download | ContactsProvider-9f48bf2c8b3b80ac3ed1c4ef6350df25beab05b3.tar.gz |
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
Change-Id: I4768ca3aa607bf3341ac8fe89fa074fe65dfedea
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/providers/contacts/VoicemailNotifier.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/com/android/providers/contacts/VoicemailNotifier.java b/src/com/android/providers/contacts/VoicemailNotifier.java index 159cec73..b4033eac 100644 --- a/src/com/android/providers/contacts/VoicemailNotifier.java +++ b/src/com/android/providers/contacts/VoicemailNotifier.java @@ -1,5 +1,6 @@ package com.android.providers.contacts; +import android.app.BroadcastOptions; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -27,6 +28,12 @@ public class VoicemailNotifier { private final String TAG = "VoicemailNotifier"; + /** + * 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 = 10000; + private final Context mContext; private final Uri mBaseUri; @@ -85,7 +92,17 @@ public class VoicemailNotifier { intent.putExtra(VoicemailContract.EXTRA_SELF_CHANGE, callingPackages.contains(component.getPackageName())); } - mContext.sendBroadcast(intent); + if (intentAction.equals(VoicemailContract.ACTION_NEW_VOICEMAIL)) { + BroadcastOptions bopts = BroadcastOptions.makeBasic(); + bopts.setTemporaryAppWhitelistDuration(VOICEMAIL_ALLOW_LIST_DURATION_MILLIS); + Log.i(TAG, String.format("sendNotification: allowMillis=%d, pkg=%s", + VOICEMAIL_ALLOW_LIST_DURATION_MILLIS, component.getPackageName())); + mContext.sendBroadcast(intent, android.Manifest.permission.READ_VOICEMAIL, + bopts.toBundle()); + } else { + mContext.sendBroadcast(intent); + } + Log.v(TAG, String.format("Sent intent. act:%s, url:%s, comp:%s," + " self_change:%s", intent.getAction(), intent.getData(), component.getClassName(), |