summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-06-19 03:06:55 (GMT)
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-06-19 03:06:55 (GMT)
commit1971bf6da6cc3b9ebbae21e720677fa80af75f60 (patch)
tree95b23f9b217fe10c85e334cedfb7620bfd58898f
parent98987d083d898431ac7864d1491d2ea4a6c8ed93 (diff)
parent6f5e17445781694a22ad63b5b9d840796c9cf431 (diff)
downloadandroid_packages_providers_DownloadProvider-1971bf6da6cc3b9ebbae21e720677fa80af75f60.zip
android_packages_providers_DownloadProvider-1971bf6da6cc3b9ebbae21e720677fa80af75f60.tar.gz
android_packages_providers_DownloadProvider-1971bf6da6cc3b9ebbae21e720677fa80af75f60.tar.bz2
Snap for 5671249 from 6f5e17445781694a22ad63b5b9d840796c9cf431 to qt-qpr1-release
Change-Id: I8886bdb3405620bf489e74fca4a5cad96995958f
-rw-r--r--AndroidManifest.xml1
-rw-r--r--src/com/android/providers/downloads/DownloadReceiver.java5
-rw-r--r--src/com/android/providers/downloads/RealSystemFacade.java6
-rw-r--r--src/com/android/providers/downloads/SystemFacade.java6
-rw-r--r--tests/src/com/android/providers/downloads/FakeSystemFacade.java10
-rw-r--r--tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java7
6 files changed, 34 insertions, 1 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 067bc93..45e2888 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -56,6 +56,7 @@
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
+ <uses-permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"/>
<application android:process="android.process.media"
android:label="@string/app_label"
diff --git a/src/com/android/providers/downloads/DownloadReceiver.java b/src/com/android/providers/downloads/DownloadReceiver.java
index f0b9de7..40b5e09 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 a0ce92c..94461a6 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 14002a1..d73fe11 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;
diff --git a/tests/src/com/android/providers/downloads/FakeSystemFacade.java b/tests/src/com/android/providers/downloads/FakeSystemFacade.java
index f381bd8..d11e0ac 100644
--- a/tests/src/com/android/providers/downloads/FakeSystemFacade.java
+++ b/tests/src/com/android/providers/downloads/FakeSystemFacade.java
@@ -16,6 +16,7 @@ import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
+import android.os.Bundle;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -37,6 +38,7 @@ public class FakeSystemFacade implements SystemFacade {
long mMaxBytesOverMobile = Long.MAX_VALUE;
long mRecommendedMaxBytesOverMobile = Long.MAX_VALUE;
List<Intent> mBroadcastsSent = new ArrayList<Intent>();
+ Bundle mLastBroadcastOptions;
boolean mCleartextTrafficPermitted = true;
private boolean mReturnActualTime = false;
private SSLContext mSSLContext = null;
@@ -49,6 +51,7 @@ public class FakeSystemFacade implements SystemFacade {
mMaxBytesOverMobile = Long.MAX_VALUE;
mRecommendedMaxBytesOverMobile = Long.MAX_VALUE;
mBroadcastsSent.clear();
+ mLastBroadcastOptions = null;
mReturnActualTime = false;
try {
mSSLContext = SSLContext.getDefault();
@@ -125,6 +128,13 @@ public class FakeSystemFacade implements SystemFacade {
@Override
public void sendBroadcast(Intent intent) {
mBroadcastsSent.add(intent);
+ mLastBroadcastOptions = null;
+ }
+
+ @Override
+ public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) {
+ mBroadcastsSent.add(intent);
+ mLastBroadcastOptions = options;
}
@Override
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
index ae0e7e5..0652f24 100644
--- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
@@ -36,6 +36,7 @@ import static java.net.HttpURLConnection.HTTP_PARTIAL;
import static java.net.HttpURLConnection.HTTP_PRECON_FAILED;
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE;
+import android.app.BroadcastOptions;
import android.app.DownloadManager;
import android.app.Notification;
import android.app.NotificationManager;
@@ -43,6 +44,7 @@ import android.content.Intent;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.Uri;
+import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.provider.Downloads;
@@ -555,6 +557,11 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
Intent broadcast = mSystemFacade.mBroadcastsSent.get(0);
assertEquals(DownloadManager.ACTION_NOTIFICATION_CLICKED, broadcast.getAction());
assertEquals(PACKAGE_NAME, broadcast.getPackage());
+
+ Bundle bOptions = mSystemFacade.mLastBroadcastOptions;
+ assertNotNull(bOptions);
+ BroadcastOptions brOptions = new BroadcastOptions(bOptions);
+ assertTrue(brOptions.allowsBackgroundActivityStarts());
}
public void testNotificationCancelDownloadClicked() throws Exception {