summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2016-03-30 20:31:05 -0600
committerJeff Sharkey <jsharkey@android.com>2016-03-30 20:31:07 -0600
commit08fa91badf0b34323c535dde6f8113e16ae94e21 (patch)
tree3ab7706d6a5480335d4941dd96822c366eb7d795 /src/com/android/providers/downloads
parenta071d48ec571dddcfcb01e4d2da2902d8d70e3d2 (diff)
downloadandroid_packages_providers_DownloadProvider-08fa91badf0b34323c535dde6f8113e16ae94e21.tar.gz
android_packages_providers_DownloadProvider-08fa91badf0b34323c535dde6f8113e16ae94e21.tar.bz2
android_packages_providers_DownloadProvider-08fa91badf0b34323c535dde6f8113e16ae94e21.zip
Avoid flashing download notifications.
When service starts, use new API to read the current set of notification tags from the system instead of clearing and starting from scratch. Bug: 27634130 Change-Id: I049fe5e445a62a52042d7638c2cb50417977435f
Diffstat (limited to 'src/com/android/providers/downloads')
-rw-r--r--src/com/android/providers/downloads/DownloadNotifier.java15
-rw-r--r--src/com/android/providers/downloads/DownloadService.java2
2 files changed, 14 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java
index 2ff8b634..a03f012c 100644
--- a/src/com/android/providers/downloads/DownloadNotifier.java
+++ b/src/com/android/providers/downloads/DownloadNotifier.java
@@ -33,11 +33,14 @@ import android.content.res.Resources;
import android.net.Uri;
import android.os.SystemClock;
import android.provider.Downloads;
+import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.LongSparseLongArray;
+import com.android.internal.util.ArrayUtils;
+
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
@@ -92,8 +95,16 @@ public class DownloadNotifier {
Context.NOTIFICATION_SERVICE);
}
- public void cancelAll() {
- mNotifManager.cancelAll();
+ public void init() {
+ synchronized (mActiveNotifs) {
+ mActiveNotifs.clear();
+ final StatusBarNotification[] notifs = mNotifManager.getActiveNotifications();
+ if (!ArrayUtils.isEmpty(notifs)) {
+ for (StatusBarNotification notif : notifs) {
+ mActiveNotifs.put(notif.getTag(), notif.getPostTime());
+ }
+ }
+ }
}
/**
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java
index 7845ce0e..7d4392e8 100644
--- a/src/com/android/providers/downloads/DownloadService.java
+++ b/src/com/android/providers/downloads/DownloadService.java
@@ -211,7 +211,7 @@ public class DownloadService extends Service {
mScanner = new DownloadScanner(this);
mNotifier = new DownloadNotifier(this);
- mNotifier.cancelAll();
+ mNotifier.init();
mObserver = new DownloadManagerContentObserver();
getContentResolver().registerContentObserver(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI,