summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadStorageProvider.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/providers/downloads/DownloadStorageProvider.java')
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java
index 4ec8e2d1..edf667d8 100644
--- a/src/com/android/providers/downloads/DownloadStorageProvider.java
+++ b/src/com/android/providers/downloads/DownloadStorageProvider.java
@@ -37,7 +37,6 @@ import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;
import android.provider.DocumentsProvider;
import android.provider.Downloads;
-import android.support.provider.DocumentArchiveHelper;
import android.text.TextUtils;
import android.util.Log;
@@ -74,14 +73,12 @@ public class DownloadStorageProvider extends DocumentsProvider {
};
private DownloadManager mDm;
- private DocumentArchiveHelper mArchiveHelper;
@Override
public boolean onCreate() {
mDm = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE);
mDm.setAccessAllDownloads(true);
mDm.setAccessFilename(true);
- mArchiveHelper = new DocumentArchiveHelper(this, ':');
return true;
}
@@ -108,8 +105,8 @@ public class DownloadStorageProvider extends DocumentsProvider {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
- row.add(Root.COLUMN_FLAGS,
- Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE);
+ row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS
+ | Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_SEARCH);
row.add(Root.COLUMN_ICON, R.mipmap.ic_launcher_download);
row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads));
row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
@@ -184,10 +181,6 @@ public class DownloadStorageProvider extends DocumentsProvider {
@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
- if (mArchiveHelper.isArchivedDocument(docId)) {
- return mArchiveHelper.queryDocument(docId, projection);
- }
-
final DownloadsCursor result =
new DownloadsCursor(projection, getContext().getContentResolver());
@@ -218,11 +211,6 @@ public class DownloadStorageProvider extends DocumentsProvider {
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder)
throws FileNotFoundException {
- if (mArchiveHelper.isArchivedDocument(docId) ||
- mArchiveHelper.isSupportedArchiveType(getDocumentType(docId))) {
- return mArchiveHelper.queryChildDocuments(docId, projection, sortOrder);
- }
-
final DownloadsCursor result =
new DownloadsCursor(projection, getContext().getContentResolver());
@@ -249,10 +237,6 @@ public class DownloadStorageProvider extends DocumentsProvider {
public Cursor queryChildDocumentsForManage(
String parentDocumentId, String[] projection, String sortOrder)
throws FileNotFoundException {
- if (mArchiveHelper.isArchivedDocument(parentDocumentId)) {
- return mArchiveHelper.queryDocument(parentDocumentId, projection);
- }
-
final DownloadsCursor result =
new DownloadsCursor(projection, getContext().getContentResolver());
@@ -314,12 +298,34 @@ public class DownloadStorageProvider extends DocumentsProvider {
}
@Override
- public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
+ public Cursor querySearchDocuments(String rootId, String query, String[] projection)
throws FileNotFoundException {
- if (mArchiveHelper.isArchivedDocument(docId)) {
- return mArchiveHelper.openDocument(docId, mode, signal);
+
+ final DownloadsCursor result =
+ new DownloadsCursor(projection, getContext().getContentResolver());
+
+ // Delegate to real provider
+ final long token = Binder.clearCallingIdentity();
+ Cursor cursor = null;
+ try {
+ cursor = mDm.query(new DownloadManager.Query().setOnlyIncludeVisibleInDownloadsUi(true)
+ .setFilterByString(query));
+ copyNotificationUri(result, cursor);
+ while (cursor.moveToNext()) {
+ includeDownloadFromCursor(result, cursor);
+ }
+ } finally {
+ IoUtils.closeQuietly(cursor);
+ Binder.restoreCallingIdentity(token);
}
+ result.start();
+ return result;
+ }
+
+ @Override
+ public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
+ throws FileNotFoundException {
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
try {
@@ -414,10 +420,6 @@ public class DownloadStorageProvider extends DocumentsProvider {
flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
}
- if (mArchiveHelper.isSupportedArchiveType(mimeType)) {
- flags |= Document.FLAG_ARCHIVE;
- }
-
final long lastModified = cursor.getLong(
cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP));
@@ -433,10 +435,6 @@ public class DownloadStorageProvider extends DocumentsProvider {
if (status != DownloadManager.STATUS_RUNNING) {
row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
}
-
- if (localFilePath != null) {
- row.add(DocumentArchiveHelper.COLUMN_LOCAL_FILE_PATH, localFilePath);
- }
}
/**