summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2016-10-03 17:05:20 -0600
committerJeff Sharkey <jsharkey@google.com>2016-10-04 19:08:03 +0000
commit968b2f2ca3fc43b762150114048b21a23bf35c73 (patch)
tree0c346f781f5f5a7c26e6df49057f5a0c0e2d582b /src/com/android/providers/downloads
parente0e69444a89bfebdcb42bb68e9999e8cb3c323a9 (diff)
downloadandroid_packages_providers_DownloadProvider-968b2f2ca3fc43b762150114048b21a23bf35c73.tar.gz
android_packages_providers_DownloadProvider-968b2f2ca3fc43b762150114048b21a23bf35c73.tar.bz2
android_packages_providers_DownloadProvider-968b2f2ca3fc43b762150114048b21a23bf35c73.zip
Launch APKs using content:// Uri with grant.
PackageInstaller now supports reading from content://, so always launch using that path. Include URI permission grants so the receiver can access the contents. Test: installed downloaded APK Bug: 31807780 Change-Id: I488d14872e80ce4a092e7db6e1c58f3fe54a54c6
Diffstat (limited to 'src/com/android/providers/downloads')
-rw-r--r--src/com/android/providers/downloads/OpenHelper.java17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/com/android/providers/downloads/OpenHelper.java b/src/com/android/providers/downloads/OpenHelper.java
index 27ab86b9..69a44922 100644
--- a/src/com/android/providers/downloads/OpenHelper.java
+++ b/src/com/android/providers/downloads/OpenHelper.java
@@ -17,10 +17,10 @@
package com.android.providers.downloads;
import static android.app.DownloadManager.COLUMN_LOCAL_FILENAME;
-import static android.app.DownloadManager.COLUMN_LOCAL_URI;
import static android.app.DownloadManager.COLUMN_MEDIA_TYPE;
import static android.app.DownloadManager.COLUMN_URI;
import static android.provider.Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI;
+
import static com.android.providers.downloads.Constants.TAG;
import android.app.DownloadManager;
@@ -30,7 +30,6 @@ import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
-import android.os.StrictMode;
import android.provider.DocumentsContract;
import android.provider.Downloads.Impl.RequestHeaders;
import android.util.Log;
@@ -51,14 +50,11 @@ public class OpenHelper {
intent.addFlags(intentFlags);
try {
- StrictMode.disableDeathOnFileUriExposure();
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Failed to start " + intent + ": " + e);
return false;
- } finally {
- StrictMode.enableDeathOnFileUriExposure();
}
}
@@ -78,7 +74,6 @@ public class OpenHelper {
return null;
}
- final Uri localUri = getCursorUri(cursor, COLUMN_LOCAL_URI);
final File file = getCursorFile(cursor, COLUMN_LOCAL_FILENAME);
String mimeType = getCursorString(cursor, COLUMN_MEDIA_TYPE);
mimeType = DownloadDrmHelper.getOriginalMimeType(context, file, mimeType);
@@ -87,20 +82,16 @@ public class OpenHelper {
Constants.STORAGE_AUTHORITY, String.valueOf(id));
final Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setDataAndType(documentUri, mimeType);
+ intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
+ | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if ("application/vnd.android.package-archive".equals(mimeType)) {
- // PackageInstaller doesn't like content URIs, so open file
- intent.setDataAndType(localUri, mimeType);
-
// Also splice in details about where it came from
final Uri remoteUri = getCursorUri(cursor, COLUMN_URI);
intent.putExtra(Intent.EXTRA_ORIGINATING_URI, remoteUri);
intent.putExtra(Intent.EXTRA_REFERRER, getRefererUri(context, id));
intent.putExtra(Intent.EXTRA_ORIGINATING_UID, getOriginatingUid(context, id));
- } else {
- intent.setDataAndType(documentUri, mimeType);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
- | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
}
return intent;