Only show queued notification when "visible."
Jeff Sharkey [Thu, 26 May 2016 16:35:18 +0000 (10:35 -0600)]
Otherwise it's confusing to see notifications for downloads that
are otherwise invisible.

Bug: 28623639
Change-Id: I1b2aeccfcca1369f66c56c441dfef68ee95c6d62

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

index 558393d..d580869 100644 (file)
@@ -19,6 +19,7 @@ package com.android.providers.downloads;
 import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE;
 import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED;
 import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION;
+import static android.provider.Downloads.Impl.STATUS_QUEUED_FOR_WIFI;
 import static android.provider.Downloads.Impl.STATUS_RUNNING;
 
 import static com.android.providers.downloads.Constants.TAG;
@@ -411,7 +412,7 @@ public class DownloadNotifier {
         final int visibility = cursor.getInt(UpdateQuery.VISIBILITY);
         final String notifPackage = cursor.getString(UpdateQuery.NOTIFICATION_PACKAGE);
 
-        if (status == Downloads.Impl.STATUS_QUEUED_FOR_WIFI) {
+        if (isQueuedAndVisible(status, visibility)) {
             return TYPE_WAITING + ":" + notifPackage;
         } else if (isActiveAndVisible(status, visibility)) {
             return TYPE_ACTIVE + ":" + notifPackage;
@@ -431,6 +432,12 @@ public class DownloadNotifier {
         return Integer.parseInt(tag.substring(0, tag.indexOf(':')));
     }
 
+    private static boolean isQueuedAndVisible(int status, int visibility) {
+        return status == STATUS_QUEUED_FOR_WIFI &&
+                (visibility == VISIBILITY_VISIBLE
+                || visibility == VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
+    }
+
     private static boolean isActiveAndVisible(int status, int visibility) {
         return status == STATUS_RUNNING &&
                 (visibility == VISIBILITY_VISIBLE