summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-06-07 11:28:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-07 11:28:40 -0700
commite3841c3b1f40f89945581951e217d5f72002ea38 (patch)
tree78dcb276810cf5010dc781d983fa934a50edca9e
parent1eccac4c7edba837d8a12792a4d3b1cfc6b0631c (diff)
parentc5b582cebe167264106df5fa7b2ae7312cd456ce (diff)
downloadandroid_packages_providers_DownloadProvider-e3841c3b1f40f89945581951e217d5f72002ea38.tar.gz
android_packages_providers_DownloadProvider-e3841c3b1f40f89945581951e217d5f72002ea38.tar.bz2
android_packages_providers_DownloadProvider-e3841c3b1f40f89945581951e217d5f72002ea38.zip
am c5b582ce: am f918429d: Uniform "when" to avoid flashing notifications.
* commit 'c5b582cebe167264106df5fa7b2ae7312cd456ce': Uniform "when" to avoid flashing notifications.
-rw-r--r--src/com/android/providers/downloads/DownloadNotification.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotification.java b/src/com/android/providers/downloads/DownloadNotification.java
index 81209b2b..bbd39f60 100644
--- a/src/com/android/providers/downloads/DownloadNotification.java
+++ b/src/com/android/providers/downloads/DownloadNotification.java
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.net.Uri;
import android.provider.Downloads;
import android.text.TextUtils;
+import android.util.SparseLongArray;
import java.util.Collection;
import java.util.HashMap;
@@ -41,6 +42,9 @@ class DownloadNotification {
HashMap <String, NotificationItem> mNotifications;
private SystemFacade mSystemFacade;
+ /** Time when each {@link DownloadInfo#mId} was first shown. */
+ private SparseLongArray mFirstShown = new SparseLongArray();
+
static final String LOGTAG = "DownloadNotification";
static final String WHERE_RUNNING =
"(" + Downloads.Impl.COLUMN_STATUS + " >= '100') AND (" +
@@ -62,6 +66,8 @@ class DownloadNotification {
*
*/
static class NotificationItem {
+ // TODO: refactor to mNotifId and avoid building Uris based on it, since
+ // they can overflow
int mId; // This first db _id for the download for the app
long mTotalCurrent = 0;
long mTotalTotal = 0;
@@ -150,13 +156,22 @@ class DownloadNotification {
final Notification.Builder builder = new Notification.Builder(mContext);
boolean hasPausedText = (item.mPausedText != null);
- int iconResource = android.R.drawable.stat_sys_download_done;
+ int iconResource = android.R.drawable.stat_sys_download;
if (hasPausedText) {
iconResource = android.R.drawable.stat_sys_warning;
}
builder.setSmallIcon(iconResource);
builder.setOngoing(true);
+ // set notification "when" to be first time this DownloadInfo.mId
+ // was encountered, which avoids fighting with other notifs.
+ long firstShown = mFirstShown.get(item.mId, -1);
+ if (firstShown == -1) {
+ firstShown = System.currentTimeMillis();
+ mFirstShown.put(item.mId, firstShown);
+ }
+ builder.setWhen(firstShown);
+
boolean hasContentText = false;
StringBuilder title = new StringBuilder(item.mTitles[0]);
if (item.mTitleCount > 1) {