summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2016-10-03 17:05:20 -0600
committerJeff Sharkey <jsharkey@android.com>2016-10-03 17:05:22 -0600
commit3b5c235df372193d6555a71c096cccf459b22b7f (patch)
treece98232d8ff0438aae327c6bee96c062c02533e8 /src/com/android/providers
parent6708a690f808f518bf927c215ebd29316dac295f (diff)
downloadandroid_packages_providers_DownloadProvider-3b5c235df372193d6555a71c096cccf459b22b7f.tar.gz
android_packages_providers_DownloadProvider-3b5c235df372193d6555a71c096cccf459b22b7f.tar.bz2
android_packages_providers_DownloadProvider-3b5c235df372193d6555a71c096cccf459b22b7f.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')
-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;