diff options
author | Michal Karpinski <mkarpinski@google.com> | 2019-06-18 15:36:17 +0100 |
---|---|---|
committer | Michal Karpinski <mkarpinski@google.com> | 2019-06-18 15:36:19 +0100 |
commit | 45bab8a5200e0423aac5af49e307f3a68388c10c (patch) | |
tree | 95b23f9b217fe10c85e334cedfb7620bfd58898f /src/com/android | |
parent | c2dc83fb4c45a8383270a90ad624af061074b8a8 (diff) | |
download | android_packages_providers_DownloadProvider-45bab8a5200e0423aac5af49e307f3a68388c10c.tar.gz android_packages_providers_DownloadProvider-45bab8a5200e0423aac5af49e307f3a68388c10c.tar.bz2 android_packages_providers_DownloadProvider-45bab8a5200e0423aac5af49e307f3a68388c10c.zip |
Whitelist DownloadManager.ACTION_NOTIFICATION_CLICKED broadcast
for background activity starts
When the DownloadManager download notification is clicked,
that broadcast is sent to an app, and the app should be able
to open activities from bg for its duration.
Bug: 135515407
Test: com.android.providers.downloads.PublicApiFunctionalTest#testNotificationClickedBroadcast
Test: manual
Change-Id: Ic1691f5bda890ceb2938ac76f4ca2a4c7e7a1160
Diffstat (limited to 'src/com/android')
3 files changed, 16 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadReceiver.java b/src/com/android/providers/downloads/DownloadReceiver.java index f0b9de71..40b5e093 100644 --- a/src/com/android/providers/downloads/DownloadReceiver.java +++ b/src/com/android/providers/downloads/DownloadReceiver.java @@ -28,6 +28,7 @@ import static com.android.providers.downloads.Helpers.getInt; import static com.android.providers.downloads.Helpers.getString; import static com.android.providers.downloads.Helpers.getSystemFacade; +import android.app.BroadcastOptions; import android.app.DownloadManager; import android.app.NotificationManager; import android.content.BroadcastReceiver; @@ -288,6 +289,8 @@ public class DownloadReceiver extends BroadcastReceiver { } } - getSystemFacade(context).sendBroadcast(appIntent); + final BroadcastOptions options = BroadcastOptions.makeBasic(); + options.setBackgroundActivityStartsAllowed(true); + getSystemFacade(context).sendBroadcast(appIntent, null, options.toBundle()); } } diff --git a/src/com/android/providers/downloads/RealSystemFacade.java b/src/com/android/providers/downloads/RealSystemFacade.java index a0ce92c3..94461a68 100644 --- a/src/com/android/providers/downloads/RealSystemFacade.java +++ b/src/com/android/providers/downloads/RealSystemFacade.java @@ -28,6 +28,7 @@ import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkInfo; +import android.os.Bundle; import android.security.NetworkSecurityPolicy; import android.security.net.config.ApplicationConfig; @@ -85,6 +86,11 @@ class RealSystemFacade implements SystemFacade { } @Override + public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) { + mContext.sendBroadcast(intent, receiverPermission, options); + } + + @Override public boolean userOwnsPackage(int uid, String packageName) throws NameNotFoundException { return mContext.getPackageManager().getApplicationInfo(packageName, 0).uid == uid; } diff --git a/src/com/android/providers/downloads/SystemFacade.java b/src/com/android/providers/downloads/SystemFacade.java index 14002a15..d73fe117 100644 --- a/src/com/android/providers/downloads/SystemFacade.java +++ b/src/com/android/providers/downloads/SystemFacade.java @@ -23,6 +23,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkInfo; +import android.os.Bundle; import java.security.GeneralSecurityException; @@ -58,6 +59,11 @@ interface SystemFacade { public void sendBroadcast(Intent intent); /** + * Send a broadcast intent with options. + */ + public void sendBroadcast(Intent intent, String receiverPermission, Bundle options); + + /** * Returns true if the specified UID owns the specified package name. */ public boolean userOwnsPackage(int uid, String pckg) throws NameNotFoundException; |