diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-02-20 16:10:39 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-02-20 16:10:39 -0800 |
commit | dd1179c09fb6ac2420292e52ea3ced395f76a7be (patch) | |
tree | 4b4ece616200d09e7b166d14eec5674dd076b989 /src/com/android/providers/downloads | |
parent | 71a53040699e713bcae839a01b7f8abd9e13bab6 (diff) | |
download | android_packages_providers_DownloadProvider-dd1179c09fb6ac2420292e52ea3ced395f76a7be.tar.gz android_packages_providers_DownloadProvider-dd1179c09fb6ac2420292e52ea3ced395f76a7be.tar.bz2 android_packages_providers_DownloadProvider-dd1179c09fb6ac2420292e52ea3ced395f76a7be.zip |
Ack, we actually need to UpdateThread.quit().
Otherwise they end up leaking. There is a race around UpdateThread
continuing to process messages before onDestroy() has been invoked,
so explicitly UpdateThread.quit() in both places.
Bug: 8233041
Change-Id: I73f1b70aedace19e23a61a3dddf4986d82f2c7d6
Diffstat (limited to 'src/com/android/providers/downloads')
-rw-r--r-- | src/com/android/providers/downloads/DownloadService.java | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 20cf6294..c8e55d7d 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -158,11 +158,9 @@ public class DownloadService extends Service { mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mStorageManager = new StorageManager(this); - if (mUpdateThread == null) { - mUpdateThread = new HandlerThread(TAG + "-UpdateThread"); - mUpdateThread.start(); - mUpdateHandler = new Handler(mUpdateThread.getLooper(), mUpdateCallback); - } + mUpdateThread = new HandlerThread(TAG + "-UpdateThread"); + mUpdateThread.start(); + mUpdateHandler = new Handler(mUpdateThread.getLooper(), mUpdateCallback); mScanner = new DownloadScanner(this); @@ -187,8 +185,9 @@ public class DownloadService extends Service { @Override public void onDestroy() { - mScanner.shutdown(); getContentResolver().unregisterContentObserver(mObserver); + mScanner.shutdown(); + mUpdateThread.quit(); if (Constants.LOGVV) { Log.v(Constants.TAG, "Service onDestroy"); } @@ -257,8 +256,7 @@ public class DownloadService extends Service { if (stopSelfResult(startId)) { if (DEBUG_LIFECYCLE) Log.v(TAG, "Nothing left; stopped"); - mUpdateHandler.removeMessages(MSG_UPDATE); - mUpdateHandler.removeMessages(MSG_FINAL_UPDATE); + mUpdateThread.quit(); } } |