diff options
author | Ben Lin <linben@google.com> | 2017-03-08 16:05:00 -0800 |
---|---|---|
committer | Ben Lin <linben@google.com> | 2017-03-10 16:02:34 -0800 |
commit | 0a1a4287841fa10274c610de31e08765ffa0c269 (patch) | |
tree | ee66dd9387b2a0bf6f2b7b83e7afb32456073688 /src/com/android/providers/downloads/DownloadStorageProvider.java | |
parent | 496bb75d2707bf190a2055103ca6f1c574530fc2 (diff) | |
download | android_packages_providers_DownloadProvider-0a1a4287841fa10274c610de31e08765ffa0c269.tar.gz android_packages_providers_DownloadProvider-0a1a4287841fa10274c610de31e08765ffa0c269.tar.bz2 android_packages_providers_DownloadProvider-0a1a4287841fa10274c610de31e08765ffa0c269.zip |
Add rawDocumentsUri handling to TrampolineActivity.
Test: Build, compiles, does not crash.
Bug: 36033829
Change-Id: I8756c6abd872e4b14cff3c604c37f82323b44c27
Diffstat (limited to 'src/com/android/providers/downloads/DownloadStorageProvider.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadStorageProvider.java | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java index cbadeb49..8e4d7900 100644 --- a/src/com/android/providers/downloads/DownloadStorageProvider.java +++ b/src/com/android/providers/downloads/DownloadStorageProvider.java @@ -61,7 +61,6 @@ import javax.annotation.concurrent.GuardedBy; */ public class DownloadStorageProvider extends FileSystemProvider { private static final String TAG = "DownloadStorageProvider"; - private static final String RAW_PREFIX = "raw:"; private static final boolean DEBUG = false; private static final String AUTHORITY = Constants.STORAGE_AUTHORITY; @@ -135,7 +134,8 @@ public class DownloadStorageProvider extends FileSystemProvider { final long token = Binder.clearCallingIdentity(); try { String newDocumentId = super.createDocument(parentDocId, mimeType, displayName); - if (!Document.MIME_TYPE_DIR.equals(mimeType) && !isRawDocId(parentDocId)) { + if (!Document.MIME_TYPE_DIR.equals(mimeType) + && !RawDocumentsHelper.isRawDocId(parentDocId)) { File newFile = getFileForDocId(newDocumentId); newDocumentId = Long.toString(mDm.addCompletedDownload( newFile.getName(), newFile.getName(), true, mimeType, @@ -153,7 +153,7 @@ public class DownloadStorageProvider extends FileSystemProvider { // Delegate to real provider final long token = Binder.clearCallingIdentity(); try { - if (isRawDocId(docId)) { + if (RawDocumentsHelper.isRawDocId(docId)) { super.deleteDocument(docId); return; } @@ -171,7 +171,7 @@ public class DownloadStorageProvider extends FileSystemProvider { final long token = Binder.clearCallingIdentity(); try { - if (isRawDocId(docId)) { + if (RawDocumentsHelper.isRawDocId(docId)) { return super.renameDocument(docId, displayName); } @@ -193,7 +193,7 @@ public class DownloadStorageProvider extends FileSystemProvider { final long token = Binder.clearCallingIdentity(); Cursor cursor = null; try { - if (isRawDocId(docId)) { + if (RawDocumentsHelper.isRawDocId(docId)) { return super.queryDocument(docId, projection); } @@ -240,7 +240,7 @@ public class DownloadStorageProvider extends FileSystemProvider { final long token = Binder.clearCallingIdentity(); Cursor cursor = null; try { - if (isRawDocId(parentDocId)) { + if (RawDocumentsHelper.isRawDocId(parentDocId)) { return super.queryChildDocuments(parentDocId, projection, sortOrder); } @@ -346,7 +346,7 @@ public class DownloadStorageProvider extends FileSystemProvider { // Delegate to real provider final long token = Binder.clearCallingIdentity(); try { - if (isRawDocId(docId)) { + if (RawDocumentsHelper.isRawDocId(docId)) { return super.openDocument(docId, mode, signal); } @@ -368,8 +368,8 @@ public class DownloadStorageProvider extends FileSystemProvider { @Override protected File getFileForDocId(String docId, boolean visible) throws FileNotFoundException { - if (isRawDocId(docId)) { - return new File(getAbsoluteFilePath(docId)); + if (RawDocumentsHelper.isRawDocId(docId)) { + return new File(RawDocumentsHelper.getAbsoluteFilePath(docId)); } if (DOC_ID_ROOT.equals(docId)) { @@ -398,7 +398,7 @@ public class DownloadStorageProvider extends FileSystemProvider { @Override protected String getDocIdForFile(File file) throws FileNotFoundException { - return RAW_PREFIX + file.getAbsolutePath(); + return RawDocumentsHelper.getDocIdForFile(file); } @Override @@ -414,9 +414,7 @@ public class DownloadStorageProvider extends FileSystemProvider { Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_DIR_SUPPORTS_CREATE); } - private static String getAbsoluteFilePath(String rawDocumentId) { - return rawDocumentId.substring(RAW_PREFIX.length()); - } + /** * Adds the entry from the cursor to the result only if the entry is valid. That is, @@ -540,10 +538,6 @@ public class DownloadStorageProvider extends FileSystemProvider { includeFile(result, null, file); } - private boolean isRawDocId(String docId) { - return docId != null && docId.startsWith(RAW_PREFIX); - } - private static File getDownloadsDirectory() { return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); } |