summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2018-03-27 09:21:54 -0600
committerJeff Sharkey <jsharkey@android.com>2018-03-27 09:21:56 -0600
commitb4fe17af341c99eb125c6d2e6bb2b85fc7c98441 (patch)
tree2c3905e0be0ed6dc278a841d58028ae18f073d4a
parent5354556113a58d07a148fae07eb217ca01413188 (diff)
downloadandroid_packages_providers_DownloadProvider-b4fe17af341c99eb125c6d2e6bb2b85fc7c98441.tar.gz
android_packages_providers_DownloadProvider-b4fe17af341c99eb125c6d2e6bb2b85fc7c98441.tar.bz2
android_packages_providers_DownloadProvider-b4fe17af341c99eb125c6d2e6bb2b85fc7c98441.zip
Return underlying MIME type of download.
Only return extension-based MIME types for raw files. Test: none Bug: 73736356 Change-Id: I228916fd408cd95f1acf43817fa43ee8646cbd4e
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java
index 514afdd3..afcba961 100644
--- a/src/com/android/providers/downloads/DownloadStorageProvider.java
+++ b/src/com/android/providers/downloads/DownloadStorageProvider.java
@@ -366,6 +366,23 @@ public class DownloadStorageProvider extends FileSystemProvider {
}
@Override
+ public String getDocumentType(String docId) throws FileNotFoundException {
+ // Delegate to real provider
+ final long token = Binder.clearCallingIdentity();
+ try {
+ if (RawDocumentsHelper.isRawDocId(docId)) {
+ return super.getDocumentType(docId);
+ }
+
+ final long id = Long.parseLong(docId);
+ final ContentResolver resolver = getContext().getContentResolver();
+ return resolver.getType(mDm.getDownloadUri(id));
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
throws FileNotFoundException {
// Delegate to real provider