diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-09-19 15:25:56 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-09-19 19:53:32 -0700 |
commit | a9ce049db87259e302e2368d2a4a1c11a94fd831 (patch) | |
tree | c024fcea7bf3983f0f9dd4de270c1412aeb42250 /packages/ExternalStorageProvider | |
parent | bdac73fec8e6d4686398654f7a74db465e6de8e0 (diff) | |
download | frameworks_base-a9ce049db87259e302e2368d2a4a1c11a94fd831.zip frameworks_base-a9ce049db87259e302e2368d2a4a1c11a94fd831.tar.gz frameworks_base-a9ce049db87259e302e2368d2a4a1c11a94fd831.tar.bz2 |
Load RootInfo in background, invalidation.
Move all RootInfo queries to background threads to avoid janking
the UI. Update passes happen on spawed task, which swaps out updated
cache results when finished. Support partial updates when only a
single package/authority has changed. Watch for change notifications
for roots, since flags can change over time.
Ignore stopped packages when in background, but query them for roots
when launching any picker UI.
Optimize management launches by treating as one-shot requests that
don't need to wait for all RootInfo.
Bug: 10600454, 10745490
Change-Id: Ibc7b15688ef6b41bd7e9dd0d7564b501e60e49a9
Diffstat (limited to 'packages/ExternalStorageProvider')
-rw-r--r-- | packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java index a917e3f..e6fbb1b 100644 --- a/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java +++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java @@ -17,6 +17,8 @@ package com.android.externalstorage; import android.content.ContentResolver; +import android.content.Context; +import android.content.pm.ProviderInfo; import android.content.res.AssetFileDescriptor; import android.database.Cursor; import android.database.MatrixCursor; @@ -52,7 +54,10 @@ import java.lang.ref.WeakReference; public class TestDocumentsProvider extends DocumentsProvider { private static final String TAG = "TestDocuments"; + private static final boolean LAG_ROOTS = false; private static final boolean CRASH_ROOTS = false; + private static final boolean REFRESH_ROOTS = false; + private static final boolean CRASH_DOCUMENT = false; private static final String MY_ROOT_ID = "myRoot"; @@ -78,17 +83,42 @@ public class TestDocumentsProvider extends DocumentsProvider { return projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION; } + private String mAuthority; + + @Override + public void attachInfo(Context context, ProviderInfo info) { + mAuthority = info.authority; + super.attachInfo(context, info); + } + @Override public Cursor queryRoots(String[] projection) throws FileNotFoundException { + Log.d(TAG, "Someone asked for our roots!"); + + if (LAG_ROOTS) SystemClock.sleep(3000); if (CRASH_ROOTS) System.exit(12); + if (REFRESH_ROOTS) { + new AsyncTask<Void, Void, Void>() { + @Override + protected Void doInBackground(Void... params) { + SystemClock.sleep(3000); + Log.d(TAG, "Notifying that something changed!!"); + final Uri uri = DocumentsContract.buildRootsUri(mAuthority); + getContext().getContentResolver().notifyChange(uri, null, false); + return null; + } + }.execute(); + } + final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection)); final RowBuilder row = result.newRow(); row.add(Root.COLUMN_ROOT_ID, MY_ROOT_ID); row.add(Root.COLUMN_ROOT_TYPE, Root.ROOT_TYPE_SERVICE); row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_RECENTS); row.add(Root.COLUMN_TITLE, "_Test title which is really long"); - row.add(Root.COLUMN_SUMMARY, "_Summary which is also super long text"); + row.add(Root.COLUMN_SUMMARY, + SystemClock.elapsedRealtime() + " summary which is also super long text"); row.add(Root.COLUMN_DOCUMENT_ID, MY_DOC_ID); row.add(Root.COLUMN_AVAILABLE_BYTES, 1024); return result; |