New PendingIntents when extras change.
Jeff Sharkey [Tue, 26 Mar 2013 20:15:43 +0000 (13:15 -0700)]
Otherwise notifications end up launching with stale download IDs.

Bug: 8417220
Change-Id: Ie72a2f4ac7b72213678ac6001af45709034492dd

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

index f832eae..df0bf84 100644 (file)
@@ -165,7 +165,8 @@ public class DownloadNotifier {
                         null, mContext, DownloadReceiver.class);
                 intent.putExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS,
                         getDownloadIds(cluster));
-                builder.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent, 0));
+                builder.setContentIntent(PendingIntent.getBroadcast(
+                        mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
                 builder.setOngoing(true);
 
             } else if (type == TYPE_COMPLETE) {
@@ -187,7 +188,8 @@ public class DownloadNotifier {
                 final Intent intent = new Intent(action, uri, mContext, DownloadReceiver.class);
                 intent.putExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS,
                         getDownloadIds(cluster));
-                builder.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent, 0));
+                builder.setContentIntent(PendingIntent.getBroadcast(
+                        mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
 
                 final Intent hideIntent = new Intent(Constants.ACTION_HIDE,
                         uri, mContext, DownloadReceiver.class);