From 8180fa5d5f72e88aadaa00f39ff39ecdfc6d3144 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Wed, 15 Mar 2017 14:20:04 -0700 Subject: Add findDocumentPath support to DownloadStorageProvider. Bug: 36254483 Change-Id: Ia53312cd79673ee85d0385f50e8dfef4d7ace3d4 --- .../providers/downloads/DownloadStorageProvider.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/com/android/providers/downloads') diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java index 8e4d7900..ee963623 100644 --- a/src/com/android/providers/downloads/DownloadStorageProvider.java +++ b/src/com/android/providers/downloads/DownloadStorageProvider.java @@ -34,6 +34,7 @@ import android.os.FileUtils; import android.os.ParcelFileDescriptor; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Document; +import android.provider.DocumentsContract.Path; import android.provider.DocumentsContract.Root; import android.provider.Downloads; import android.text.TextUtils; @@ -123,6 +124,22 @@ public class DownloadStorageProvider extends FileSystemProvider { return result; } + @Override + public Path findDocumentPath(String parentDocId, String docId) throws FileNotFoundException { + + if (parentDocId == null) { + parentDocId = DOC_ID_ROOT; + } + + final File parent = getFileForDocId(parentDocId); + + final File doc = getFileForDocId(docId); + + final String rootId = (parentDocId == null) ? DOC_ID_ROOT : null; + + return new Path(rootId, findDocumentPath(parent, doc)); + } + /** * Calls on {@link FileSystemProvider#createDocument(String, String, String)}, and then creates * a new database entry in {@link DownloadManager} if it is not a raw file and not a folder. -- cgit v1.2.3