From ebcc93801eb9545004536587d10f82db378aeab5 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 20 Jul 2012 16:06:35 -0700 Subject: Reduce deletion logging. Bug: 6544953 Change-Id: I4157c67b9b9cddab4ade795c328a202f6a230f95 --- src/com/android/providers/downloads/DownloadService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/com/android/providers/downloads/DownloadService.java') diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 3b566f8e..55efefcf 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -38,7 +38,6 @@ import android.os.RemoteException; import android.provider.Downloads; import android.text.TextUtils; import android.util.Log; -import android.util.Slog; import com.android.internal.util.IndentingPrintWriter; import com.google.android.collect.Maps; @@ -483,7 +482,9 @@ public class DownloadService extends Service { 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); @@ -559,7 +560,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(); } -- cgit v1.2.3 From 36612d27b67ff2e79ffff8eb12d95d2058abde02 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 24 Jul 2012 17:42:25 -0700 Subject: Move notification tests to LittleMock. Directly mock NotificationManager instead of using SystemFacade. Change-Id: If932d26e23816e8674469c275a828701cce5fc2d --- src/com/android/providers/downloads/DownloadService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/com/android/providers/downloads/DownloadService.java') diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 55efefcf..7030deae 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -19,6 +19,7 @@ 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,6 +66,7 @@ public class DownloadService extends Service { /** Class to handle Notification Manager updates */ private DownloadNotification mNotifier; + private NotificationManager mNotifManager; /** * The Service's view of the list of downloads, mapping download IDs to the corresponding info @@ -221,7 +223,9 @@ public class DownloadService extends Service { mMediaScannerConnection = new MediaScannerConnection(); mNotifier = new DownloadNotification(this, mSystemFacade); - mSystemFacade.cancelAllNotifications(); + mNotifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + mNotifManager.cancelAll(); + mStorageManager = StorageManager.getInstance(getApplicationContext()); updateFromProvider(); } @@ -464,7 +468,7 @@ public class DownloadService extends Service { !Downloads.Impl.isStatusCompleted(oldStatus) && Downloads.Impl.isStatusCompleted(info.mStatus); if (lostVisibility || justCompleted) { - mSystemFacade.cancelNotification(info.mId); + mNotifManager.cancel((int) info.mId); } info.startIfReady(now, mStorageManager); @@ -487,7 +491,7 @@ public class DownloadService extends Service { } new File(info.mFileName).delete(); } - mSystemFacade.cancelNotification(info.mId); + mNotifManager.cancel((int) info.mId); mDownloads.remove(info.mId); } -- cgit v1.2.3 From 70b5c30db87b3405e2e001c06c4a4a5dd6e25b72 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 5 Oct 2012 15:09:00 -0700 Subject: Skip scanning a file which will be deleted. When deleting a download, don't bother scanning it, since we'll just delete it moments later. This was already racy since it didn't even wait for the scan to complete. Bug: 7256243 Change-Id: I8c3b96823d94bc1688ef336cb45746ccd35fc760 --- src/com/android/providers/downloads/DownloadService.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/com/android/providers/downloads/DownloadService.java') diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 7030deae..8380830a 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -479,9 +479,6 @@ 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; } -- cgit v1.2.3