From ff0220f5b4624049a1052bd868d7706eee5a0daf Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 26 Mar 2013 11:18:16 -0700 Subject: Unregister observer when tearing down service. Also reduce and adjust some logging. Bug: 8470658 Change-Id: Ia1f1cbd315ded04edd2113506e5c5a1db5ec85b4 --- src/com/android/providers/downloads/DownloadService.java | 2 ++ src/com/android/providers/downloads/DownloadThread.java | 8 ++++---- src/com/android/providers/downloads/StorageManager.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 6c61193c..7d746cca 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -268,6 +268,8 @@ public class DownloadService extends Service { if (stopSelfResult(startId)) { if (DEBUG_LIFECYCLE) Log.v(TAG, "Nothing left; stopped"); + getContentResolver().unregisterContentObserver(mObserver); + mScanner.shutdown(); mUpdateThread.quit(); } } diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java index f1add241..6a0eb47e 100644 --- a/src/com/android/providers/downloads/DownloadThread.java +++ b/src/com/android/providers/downloads/DownloadThread.java @@ -193,7 +193,7 @@ public class DownloadThread implements Runnable { // while performing download, register for rules updates netPolicy.registerListener(mPolicyListener); - Log.i(Constants.TAG, "Initiating download " + mInfo.mId); + Log.i(Constants.TAG, "Download " + mInfo.mId + " starting"); // Remember which network this download started on; used to // determine if errors were due to network changes. @@ -216,9 +216,6 @@ public class DownloadThread implements Runnable { executeDownload(state); - if (Constants.LOGV) { - Log.v(Constants.TAG, "download completed for " + mInfo.mUri); - } finalizeDestinationFile(state); finalStatus = Downloads.Impl.STATUS_SUCCESS; } catch (StopRequestException error) { @@ -272,6 +269,9 @@ public class DownloadThread implements Runnable { cleanupDestination(state, finalStatus); notifyDownloadCompleted(state, finalStatus, errorMsg, numFailed); + Log.i(Constants.TAG, "Download " + mInfo.mId + " finished with status " + + Downloads.Impl.statusToString(finalStatus)); + netPolicy.unregisterListener(mPolicyListener); if (wakeLock != null) { diff --git a/src/com/android/providers/downloads/StorageManager.java b/src/com/android/providers/downloads/StorageManager.java index 8ca17300..deb412e7 100644 --- a/src/com/android/providers/downloads/StorageManager.java +++ b/src/com/android/providers/downloads/StorageManager.java @@ -358,7 +358,7 @@ class StorageManager { * This is not a very common occurrence. So, do this only once in a while. */ private void removeSpuriousFiles() { - if (true || Constants.LOGV) { + if (Constants.LOGV) { Log.i(Constants.TAG, "in removeSpuriousFiles"); } // get a list of all files in system cache dir and downloads data dir -- cgit v1.2.3