Always update notifications, media scanner.
Jeff Sharkey [Fri, 4 Oct 2013 23:02:50 +0000 (16:02 -0700)]
insert() was trying to be too clever, and it would end up delaying
the media scanner until the next download happened.  This resulted
in duplicate photos in DocumentsUI.

Bug: 11081685
Change-Id: Ic9549ede38118372849119dd3a21415a4723e9f5

src/com/android/providers/downloads/DownloadProvider.java

index 750ee0f..ad3cf7a 100644 (file)
@@ -683,23 +683,12 @@ public final class DownloadProvider extends ContentProvider {
         }
 
         insertRequestHeaders(db, rowID, values);
-        /*
-         * requests coming from
-         * DownloadManager.addCompletedDownload(String, String, String,
-         * boolean, String, String, long) need special treatment
-         */
-        Context context = getContext();
-        if (values.getAsInteger(Downloads.Impl.COLUMN_DESTINATION) ==
-                Downloads.Impl.DESTINATION_NON_DOWNLOADMANAGER_DOWNLOAD) {
-            // When notification is requested, kick off service to process all
-            // relevant downloads.
-            if (Downloads.Impl.isNotificationToBeDisplayed(vis)) {
-                context.startService(new Intent(context, DownloadService.class));
-            }
-        } else {
-            context.startService(new Intent(context, DownloadService.class));
-        }
         notifyContentChanged(uri, match);
+
+        // Always start service to handle notifications and/or scanning
+        final Context context = getContext();
+        context.startService(new Intent(context, DownloadService.class));
+
         return ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, rowID);
     }