From 71a53040699e713bcae839a01b7f8abd9e13bab6 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 20 Feb 2013 15:54:26 -0800 Subject: Only use single UpdateThread. Since DownloadService starts and stops frequently, recycle a single UpdateThread across invocations. Bug: 8233041 Change-Id: I07756fb6bfdbad811cbd58e628fdfdbf63d71bf8 --- src/com/android/providers/downloads/DownloadService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java index 66d3be96..20cf6294 100644 --- a/src/com/android/providers/downloads/DownloadService.java +++ b/src/com/android/providers/downloads/DownloadService.java @@ -158,9 +158,11 @@ public class DownloadService extends Service { mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mStorageManager = new StorageManager(this); - mUpdateThread = new HandlerThread(TAG + "-UpdateThread"); - mUpdateThread.start(); - mUpdateHandler = new Handler(mUpdateThread.getLooper(), mUpdateCallback); + if (mUpdateThread == null) { + mUpdateThread = new HandlerThread(TAG + "-UpdateThread"); + mUpdateThread.start(); + mUpdateHandler = new Handler(mUpdateThread.getLooper(), mUpdateCallback); + } mScanner = new DownloadScanner(this); @@ -185,7 +187,6 @@ public class DownloadService extends Service { @Override public void onDestroy() { - mUpdateThread.quit(); mScanner.shutdown(); getContentResolver().unregisterContentObserver(mObserver); if (Constants.LOGVV) { -- cgit v1.2.3