summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-06-07 11:10:18 -0700
committerJeff Sharkey <jsharkey@android.com>2012-06-07 11:10:18 -0700
commitf918429d0c1927a19d688baa26a07c2c65765580 (patch)
tree1e80902f89b6d250f60e210c0f3379f88a523114
parent03fcf94300996a9cb7889ca03ddb2c62ca2ba606 (diff)
downloadandroid_packages_providers_DownloadProvider-f918429d0c1927a19d688baa26a07c2c65765580.tar.gz
android_packages_providers_DownloadProvider-f918429d0c1927a19d688baa26a07c2c65765580.tar.bz2
android_packages_providers_DownloadProvider-f918429d0c1927a19d688baa26a07c2c65765580.zip
Uniform "when" to avoid flashing notifications.
When showing a download, remember the first timestamp when we showed a notification, and use that time as "when" for all future updates to avoid flashing. Also bring back icon animation that had regressed. Bug: 6596416, 6237256 Change-Id: Ifdc5dc6870dac047515151c1b088e6e379b6a063
-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) {