summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTodd Kennedy <toddke@google.com>2015-06-19 14:47:45 -0700
committerTodd Kennedy <toddke@google.com>2015-06-19 14:47:45 -0700
commitf775c9840f8f9520ab3dc859597cb34624213363 (patch)
tree49136a74599821b208199365c1ae89b1347480b6 /src
parente3960ea97d5ddee80e5237796d577892e42a28cb (diff)
downloadandroid_packages_providers_DownloadProvider-f775c9840f8f9520ab3dc859597cb34624213363.tar.gz
android_packages_providers_DownloadProvider-f775c9840f8f9520ab3dc859597cb34624213363.tar.bz2
android_packages_providers_DownloadProvider-f775c9840f8f9520ab3dc859597cb34624213363.zip
Create a handler thread
The onCreate() method [where we initialize the handler] runs on the main thread. This means the ParcelFileDescriptor also runs tasks involving disk access on the main thread. We need to create a separate thread to run the Content Provider's handler. Bug: 19718299 Change-Id: Ia3661fafd3442ad6260f04253ba24ddf83b176b2
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index b19da709..2087c227 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -36,6 +36,7 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Environment;
import android.os.Handler;
+import android.os.HandlerThread;
import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor.OnCloseListener;
import android.os.Process;
@@ -441,7 +442,10 @@ public final class DownloadProvider extends ContentProvider {
mSystemFacade = new RealSystemFacade(getContext());
}
- mHandler = new Handler();
+ HandlerThread handlerThread =
+ new HandlerThread("DownloadProvider handler", Process.THREAD_PRIORITY_BACKGROUND);
+ handlerThread.start();
+ mHandler = new Handler(handlerThread.getLooper());
mOpenHelper = new DatabaseHelper(getContext());
// Initialize the system uid