diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-09-02 20:58:55 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-02 20:58:55 -0700 |
commit | 92a373d02498d860e98c7fcae6bd7fa8d4be00a4 (patch) | |
tree | 5d1eaac09d2af13a75a0948540e2179c4f599312 | |
parent | c6530c843d5958054e1156fb60a607e1190e5191 (diff) | |
parent | 747c95dcd7ba22184c71067673edf6dfd336f9fe (diff) | |
download | android_packages_providers_DownloadProvider-92a373d02498d860e98c7fcae6bd7fa8d4be00a4.tar.gz android_packages_providers_DownloadProvider-92a373d02498d860e98c7fcae6bd7fa8d4be00a4.tar.bz2 android_packages_providers_DownloadProvider-92a373d02498d860e98c7fcae6bd7fa8d4be00a4.zip |
am 747c95dc: am 0ceb40f6: Merge "New recent documents behavior." into klp-dev
* commit '747c95dcd7ba22184c71067673edf6dfd336f9fe':
New recent documents behavior.
-rw-r--r-- | src/com/android/providers/downloads/DownloadStorageProvider.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java index 728a5aa0..bc2ec0c7 100644 --- a/src/com/android/providers/downloads/DownloadStorageProvider.java +++ b/src/com/android/providers/downloads/DownloadStorageProvider.java @@ -81,7 +81,8 @@ public class DownloadStorageProvider extends DocumentsProvider { row.offer(Root.COLUMN_ROOT_ID, DOC_ID_ROOT); row.offer(Root.COLUMN_ROOT_TYPE, Root.ROOT_TYPE_SHORTCUT); row.offer(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_PROVIDES_AUDIO - | Root.FLAG_PROVIDES_VIDEO | Root.FLAG_PROVIDES_IMAGES); + | Root.FLAG_PROVIDES_VIDEO | Root.FLAG_PROVIDES_IMAGES + | Root.FLAG_SUPPORTS_RECENTS); row.offer(Root.COLUMN_ICON, R.mipmap.ic_launcher_download); row.offer(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads)); row.offer(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT); @@ -145,6 +146,27 @@ public class DownloadStorageProvider extends DocumentsProvider { } @Override + public Cursor queryRecentDocuments(String rootId, String[] projection) + throws FileNotFoundException { + final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection)); + + // Delegate to real provider + final long token = Binder.clearCallingIdentity(); + Cursor cursor = null; + try { + cursor = mDm.query(new DownloadManager.Query().setOnlyIncludeVisibleInDownloadsUi(true) + .setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL)); + while (cursor.moveToNext() && result.getCount() < 12) { + includeDownloadFromCursor(result, cursor); + } + } finally { + IoUtils.closeQuietly(cursor); + Binder.restoreCallingIdentity(token); + } + return result; + } + + @Override public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal) throws FileNotFoundException { if (!"r".equals(mode)) { |