diff options
Diffstat (limited to 'src/com/android/providers/downloads/DownloadService.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadService.java | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 8380830a..b97346b2 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; @@ -40,6 +39,7 @@ import android.provider.Downloads; import android.text.TextUtils; import android.util.Log; +import com.android.internal.annotations.GuardedBy; import com.android.internal.util.IndentingPrintWriter; import com.google.android.collect.Maps; import com.google.common.annotations.VisibleForTesting; @@ -65,8 +65,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 @@ -74,6 +73,7 @@ public class DownloadService extends Service { * downloads based on this data, so that it can deal with situation where the data in the * content provider changes or disappears. */ + @GuardedBy("mDownloads") private Map<Long, DownloadInfo> mDownloads = Maps.newHashMap(); /** @@ -222,9 +222,8 @@ 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); + mNotifier.cancelAll(); mStorageManager = StorageManager.getInstance(getApplicationContext()); updateFromProvider(); @@ -359,7 +358,7 @@ public class DownloadService extends Service { } } } - mNotifier.updateNotification(mDownloads.values()); + mNotifier.updateWith(mDownloads.values()); if (mustScan) { bindMediaScanner(); } else { @@ -459,18 +458,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 +475,6 @@ public class DownloadService extends Service { } new File(info.mFileName).delete(); } - mNotifManager.cancel((int) info.mId); mDownloads.remove(info.mId); } |