diff options
Diffstat (limited to 'src/com/android/providers/downloads/DownloadService.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadService.java | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 3b566f8e..b97346b2 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -38,8 +38,8 @@ import android.os.RemoteException; import android.provider.Downloads; import android.text.TextUtils; import android.util.Log; -import android.util.Slog; +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,7 +65,7 @@ public class DownloadService extends Service { private DownloadManagerContentObserver mObserver; /** Class to handle Notification Manager updates */ - private DownloadNotification mNotifier; + private DownloadNotifier mNotifier; /** * The Service's view of the list of downloads, mapping download IDs to the corresponding info @@ -73,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(); /** @@ -221,8 +222,9 @@ public class DownloadService extends Service { mMediaScannerConnecting = false; mMediaScannerConnection = new MediaScannerConnection(); - mNotifier = new DownloadNotification(this, mSystemFacade); - mSystemFacade.cancelAllNotifications(); + mNotifier = new DownloadNotifier(this); + mNotifier.cancelAll(); + mStorageManager = StorageManager.getInstance(getApplicationContext()); updateFromProvider(); } @@ -356,7 +358,7 @@ public class DownloadService extends Service { } } } - mNotifier.updateNotification(mDownloads.values()); + mNotifier.updateWith(mDownloads.values()); if (mustScan) { bindMediaScanner(); } else { @@ -456,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) { - mSystemFacade.cancelNotification(info.mId); - } - info.startIfReady(now, mStorageManager); } @@ -476,17 +466,15 @@ public class DownloadService extends Service { */ private void deleteDownloadLocked(long id) { DownloadInfo info = mDownloads.get(id); - if (info.shouldScanFile()) { - scanFile(info, false, false); - } if (info.mStatus == Downloads.Impl.STATUS_RUNNING) { info.mStatus = Downloads.Impl.STATUS_CANCELED; } if (info.mDestination != Downloads.Impl.DESTINATION_EXTERNAL && info.mFileName != null) { - Slog.d(TAG, "deleteDownloadLocked() deleting " + info.mFileName); + if (Constants.LOGVV) { + Log.d(TAG, "deleteDownloadLocked() deleting " + info.mFileName); + } new File(info.mFileName).delete(); } - mSystemFacade.cancelNotification(info.mId); mDownloads.remove(info.mId); } @@ -559,7 +547,9 @@ public class DownloadService extends Service { private void deleteFileIfExists(String path) { try { if (!TextUtils.isEmpty(path)) { - Slog.d(TAG, "deleteFileIfExists() deleting " + path); + if (Constants.LOGVV) { + Log.d(TAG, "deleteFileIfExists() deleting " + path); + } File file = new File(path); file.delete(); } |