From db9020e34a49a3eedc42d67ada0ae98ee29e813f Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 2 Sep 2013 15:30:28 -0700 Subject: New recent documents behavior. Bug: 10593596 Change-Id: I708d2396266d083a494e57eab2637471e54e1cdc --- .../downloads/DownloadStorageProvider.java | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src') 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); @@ -144,6 +145,27 @@ public class DownloadStorageProvider extends DocumentsProvider { return result; } + @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 { -- cgit v1.2.3