summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-09-10 17:02:08 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-10 17:02:08 -0700
commit36276c61fc07509b65b06f8ee4be2bd9e82dfd91 (patch)
tree82f3f3e370bd6d9c4fac33e87fd11b7f4fb4087d
parent7e9b6e27cdfa1354fe3fe39736cc5b551bc7c347 (diff)
parent1aad6c663ee188b02449e5e4d3e40e5c09c8fc14 (diff)
downloadandroid_packages_providers_DownloadProvider-36276c61fc07509b65b06f8ee4be2bd9e82dfd91.tar.gz
android_packages_providers_DownloadProvider-36276c61fc07509b65b06f8ee4be2bd9e82dfd91.tar.bz2
android_packages_providers_DownloadProvider-36276c61fc07509b65b06f8ee4be2bd9e82dfd91.zip
am 1aad6c66: Omit duplicate images, query for management UI.
* commit '1aad6c663ee188b02449e5e4d3e40e5c09c8fc14': Omit duplicate images, query for management UI.
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java
index 9315ea32..7268c5c6 100644
--- a/src/com/android/providers/downloads/DownloadStorageProvider.java
+++ b/src/com/android/providers/downloads/DownloadStorageProvider.java
@@ -31,6 +31,7 @@ import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;
import android.provider.DocumentsProvider;
+import android.text.TextUtils;
import libcore.io.IoUtils;
@@ -56,14 +57,11 @@ public class DownloadStorageProvider extends DocumentsProvider {
};
private DownloadManager mDm;
- private DownloadManager.Query mBaseQuery;
@Override
public boolean onCreate() {
mDm = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE);
mDm.setAccessAllDownloads(true);
- mBaseQuery = new DownloadManager.Query().setOnlyIncludeVisibleInDownloadsUi(true);
-
return true;
}
@@ -138,7 +136,31 @@ public class DownloadStorageProvider extends DocumentsProvider {
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
- cursor = mDm.query(mBaseQuery);
+ cursor = mDm.query(new DownloadManager.Query().setOnlyIncludeVisibleInDownloadsUi(true)
+ .setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL));
+ copyNotificationUri(result, cursor);
+ while (cursor.moveToNext()) {
+ includeDownloadFromCursor(result, cursor);
+ }
+ } finally {
+ IoUtils.closeQuietly(cursor);
+ Binder.restoreCallingIdentity(token);
+ }
+ return result;
+ }
+
+ @Override
+ public Cursor queryChildDocumentsForManage(
+ String parentDocumentId, String[] projection, String sortOrder)
+ 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));
copyNotificationUri(result, cursor);
while (cursor.moveToNext()) {
includeDownloadFromCursor(result, cursor);
@@ -163,6 +185,18 @@ public class DownloadStorageProvider extends DocumentsProvider {
.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL));
copyNotificationUri(result, cursor);
while (cursor.moveToNext() && result.getCount() < 12) {
+ final String mimeType = cursor.getString(
+ cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIA_TYPE));
+ final String uri = cursor.getString(
+ cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIAPROVIDER_URI));
+
+ // Skip images that have been inserted into the MediaStore so we
+ // don't duplicate them in the recents list.
+ if (mimeType == null
+ || (mimeType.startsWith("image/") && !TextUtils.isEmpty(uri))) {
+ continue;
+ }
+
includeDownloadFromCursor(result, cursor);
}
} finally {