summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-03-25 17:45:19 -0700
committerJeff Sharkey <jsharkey@android.com>2013-03-25 17:45:19 -0700
commit97d507d95f9885ceb12f2ce2483361b5ed265f9f (patch)
treecfc4d225cc6b8c22cdc05476f38b3903bed1e44b /src/com/android
parent703bc3a83056a878a83e263b992fb5331b84535f (diff)
downloadandroid_packages_providers_DownloadProvider-97d507d95f9885ceb12f2ce2483361b5ed265f9f.tar.gz
android_packages_providers_DownloadProvider-97d507d95f9885ceb12f2ce2483361b5ed265f9f.tar.bz2
android_packages_providers_DownloadProvider-97d507d95f9885ceb12f2ce2483361b5ed265f9f.zip
Avoid sending messages after HandlerThread.quit().
Bug: 8470658 Change-Id: I4cfd6a01c2c2d845a72d3f58c29eec8b44176537
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/providers/downloads/DownloadService.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java
index 6c61193c..c519faaf 100644
--- a/src/com/android/providers/downloads/DownloadService.java
+++ b/src/com/android/providers/downloads/DownloadService.java
@@ -189,6 +189,7 @@ public class DownloadService extends Service {
getContentResolver().unregisterContentObserver(mObserver);
mScanner.shutdown();
mUpdateThread.quit();
+ mUpdateThread = null;
if (Constants.LOGVV) {
Log.v(Constants.TAG, "Service onDestroy");
}
@@ -199,8 +200,10 @@ public class DownloadService extends Service {
* Enqueue an {@link #updateLocked()} pass to occur in future.
*/
private void enqueueUpdate() {
- mUpdateHandler.removeMessages(MSG_UPDATE);
- mUpdateHandler.obtainMessage(MSG_UPDATE, mLastStartId, -1).sendToTarget();
+ if (mUpdateThread != null) {
+ mUpdateHandler.removeMessages(MSG_UPDATE);
+ mUpdateHandler.obtainMessage(MSG_UPDATE, mLastStartId, -1).sendToTarget();
+ }
}
/**
@@ -208,10 +211,12 @@ public class DownloadService extends Service {
* catch any finished operations that didn't trigger an update pass.
*/
private void enqueueFinalUpdate() {
- mUpdateHandler.removeMessages(MSG_FINAL_UPDATE);
- mUpdateHandler.sendMessageDelayed(
- mUpdateHandler.obtainMessage(MSG_FINAL_UPDATE, mLastStartId, -1),
- 5 * MINUTE_IN_MILLIS);
+ if (mUpdateThread != null) {
+ mUpdateHandler.removeMessages(MSG_FINAL_UPDATE);
+ mUpdateHandler.sendMessageDelayed(
+ mUpdateHandler.obtainMessage(MSG_FINAL_UPDATE, mLastStartId, -1),
+ 5 * MINUTE_IN_MILLIS);
+ }
}
private static final int MSG_UPDATE = 1;
@@ -269,6 +274,7 @@ public class DownloadService extends Service {
if (stopSelfResult(startId)) {
if (DEBUG_LIFECYCLE) Log.v(TAG, "Nothing left; stopped");
mUpdateThread.quit();
+ mUpdateThread = null;
}
}