diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-08-02 21:58:17 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2012-11-09 15:40:00 -0800 |
commit | a40a349c0107660bfb4004467550725a3ca3ec97 (patch) | |
tree | 3fb1f96ad2d1da1d346fd32f239d1ee8ef149376 /src/com/android/providers/downloads/DownloadService.java | |
parent | 2fa007ef678b2283d47d007aa3dc91af683cc52c (diff) | |
download | android_packages_providers_DownloadProvider-a40a349c0107660bfb4004467550725a3ca3ec97.tar.gz android_packages_providers_DownloadProvider-a40a349c0107660bfb4004467550725a3ca3ec97.tar.bz2 android_packages_providers_DownloadProvider-a40a349c0107660bfb4004467550725a3ca3ec97.zip |
Rewrite of download notifications.
Switch to using new inbox-style notifications when collapsing multiple
downloads. Correctly handles clustering, including cancellation of
stale notifications. All notifications are now handled in a single
class, making it easier to reason about correctness.
Fixed bugs around handling of visibility flags. Move away from using
"int" as internal keys, since they can overflow. Started work for
time estimates, will finish in a future CL.
Explicitly pass all relevant IDs to DownloadReceiver instead of doing
a second racy query. Fix StrictMode warnings when querying in
DownloadReceiver.
Bug: 6777872, 5463678, 6663547, 6967346, 6634261, 5608365
Change-Id: I5eb47b73b90b6250acec2ce5bf8d7a274ed9d3a9
Diffstat (limited to 'src/com/android/providers/downloads/DownloadService.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadService.java | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 8380830a..0a16a7d1 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -19,7 +19,6 @@ package com.android.providers.downloads; import static com.android.providers.downloads.Constants.TAG; import android.app.AlarmManager; -import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.ComponentName; @@ -65,8 +64,7 @@ public class DownloadService extends Service { private DownloadManagerContentObserver mObserver; /** Class to handle Notification Manager updates */ - private DownloadNotification mNotifier; - private NotificationManager mNotifManager; + private DownloadNotifier mNotifier; /** * The Service's view of the list of downloads, mapping download IDs to the corresponding info @@ -222,9 +220,7 @@ public class DownloadService extends Service { mMediaScannerConnecting = false; mMediaScannerConnection = new MediaScannerConnection(); - mNotifier = new DownloadNotification(this, mSystemFacade); - mNotifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - mNotifManager.cancelAll(); + mNotifier = new DownloadNotifier(this); mStorageManager = StorageManager.getInstance(getApplicationContext()); updateFromProvider(); @@ -359,7 +355,7 @@ public class DownloadService extends Service { } } } - mNotifier.updateNotification(mDownloads.values()); + mNotifier.updateWith(mDownloads.values()); if (mustScan) { bindMediaScanner(); } else { @@ -459,18 +455,6 @@ public class DownloadService extends Service { Log.v(Constants.TAG, "processing updated download " + info.mId + ", status: " + info.mStatus); } - - boolean lostVisibility = - oldVisibility == Downloads.Impl.VISIBILITY_VISIBLE_NOTIFY_COMPLETED - && info.mVisibility != Downloads.Impl.VISIBILITY_VISIBLE_NOTIFY_COMPLETED - && Downloads.Impl.isStatusCompleted(info.mStatus); - boolean justCompleted = - !Downloads.Impl.isStatusCompleted(oldStatus) - && Downloads.Impl.isStatusCompleted(info.mStatus); - if (lostVisibility || justCompleted) { - mNotifManager.cancel((int) info.mId); - } - info.startIfReady(now, mStorageManager); } @@ -488,7 +472,6 @@ public class DownloadService extends Service { } new File(info.mFileName).delete(); } - mNotifManager.cancel((int) info.mId); mDownloads.remove(info.mId); } |