summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-10-01 17:57:41 -0700
committerJeff Sharkey <jsharkey@android.com>2013-10-02 08:54:02 -0700
commitd01571e6d4e1c403534e19142720530d324eac9b (patch)
tree397106adf0cda15ea986a3d33e1e6ba3ba05c074 /core
parentee3e1603fdbbe24b0cbf3cb85c456696cf3b7941 (diff)
downloadframeworks_base-d01571e6d4e1c403534e19142720530d324eac9b.zip
frameworks_base-d01571e6d4e1c403534e19142720530d324eac9b.tar.gz
frameworks_base-d01571e6d4e1c403534e19142720530d324eac9b.tar.bz2
Isolate calls to each remote DocumentsProvider.
All background work is going through AsyncTasks, which uses a shared thread pool. Even with the new ContentProviderClient logic to detect ANRs, the UI can still appear to be unresponsive for 20 seconds, even if the user attempted to switch to a different backend. In the worst case, a backlog of thumbnail requests would end up wedging Loaders for a long time, since they all share the same THREAD_POOL_EXECUTOR. This change isolates calls to each provider onto their own thread, which they're free to wedge and recover from over time. It also means we no longer need a dedicated thread pool for recents loading, and can use a simpler Semaphore instead. Disables thumbnails in recents on svelte devices. Bug: 10993301, 11014856 Change-Id: I7f8a5bbb5f64437e006cb2c48b7e854136d5c38c
Diffstat (limited to 'core')
-rw-r--r--core/java/android/content/AsyncTaskLoader.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/java/android/content/AsyncTaskLoader.java b/core/java/android/content/AsyncTaskLoader.java
index 612c67f..eb7426e 100644
--- a/core/java/android/content/AsyncTaskLoader.java
+++ b/core/java/android/content/AsyncTaskLoader.java
@@ -26,6 +26,7 @@ import android.util.TimeUtils;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
/**
* Abstract Loader that provides an {@link AsyncTask} to do the work. See
@@ -123,6 +124,8 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> {
}
}
+ private final Executor mExecutor;
+
volatile LoadTask mTask;
volatile LoadTask mCancellingTask;
@@ -131,7 +134,13 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> {
Handler mHandler;
public AsyncTaskLoader(Context context) {
+ this(context, AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+
+ /** {@hide} */
+ public AsyncTaskLoader(Context context, Executor executor) {
super(context);
+ mExecutor = executor;
}
/**
@@ -223,7 +232,7 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> {
}
}
if (DEBUG) Slog.v(TAG, "Executing: " + mTask);
- mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
+ mTask.executeOnExecutor(mExecutor, (Void[]) null);
}
}