diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-10-01 17:57:41 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-10-02 08:54:02 -0700 |
commit | d01571e6d4e1c403534e19142720530d324eac9b (patch) | |
tree | 397106adf0cda15ea986a3d33e1e6ba3ba05c074 /packages/ExternalStorageProvider | |
parent | ee3e1603fdbbe24b0cbf3cb85c456696cf3b7941 (diff) | |
download | frameworks_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 'packages/ExternalStorageProvider')
-rw-r--r-- | packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java index e9f2c71..0caddcc 100644 --- a/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java +++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java @@ -66,6 +66,7 @@ public class TestDocumentsProvider extends DocumentsProvider { private static final boolean CHILD_WEDGE = false; private static final boolean CHILD_CRASH = false; + private static final boolean THUMB_HUNDREDS = false; private static final boolean THUMB_WEDGE = false; private static final boolean THUMB_CRASH = false; @@ -225,6 +226,12 @@ public class TestDocumentsProvider extends DocumentsProvider { includeFile(result, "localfile3", 0); includeFile(result, "localfile4", 0); + if (THUMB_HUNDREDS) { + for (int i = 0; i < 256; i++) { + includeFile(result, "i maded u an picshure", Document.FLAG_SUPPORTS_THUMBNAIL); + } + } + synchronized (this) { // Try picking up an existing network fetch CloudTask task = mTask != null ? mTask.get() : null; @@ -292,7 +299,7 @@ public class TestDocumentsProvider extends DocumentsProvider { public AssetFileDescriptor openDocumentThumbnail( String docId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException { - if (THUMB_WEDGE) SystemClock.sleep(Integer.MAX_VALUE); + if (THUMB_WEDGE) wedgeUntilCanceled(signal); if (THUMB_CRASH) System.exit(12); final Bitmap bitmap = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_8888); @@ -332,6 +339,18 @@ public class TestDocumentsProvider extends DocumentsProvider { return true; } + private static void wedgeUntilCanceled(CancellationSignal signal) { + if (signal != null) { + while (true) { + signal.throwIfCanceled(); + SystemClock.sleep(500); + } + } else { + Log.w(TAG, "WEDGING WITHOUT A CANCELLATIONSIGNAL"); + SystemClock.sleep(Integer.MAX_VALUE); + } + } + private static void includeFile(MatrixCursor result, String docId, int flags) { final RowBuilder row = result.newRow(); row.add(Document.COLUMN_DOCUMENT_ID, docId); |