diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-09-19 19:59:22 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-19 19:59:22 -0700 |
commit | 89dec7e6e9ab98141de89096ef052cb2c158c557 (patch) | |
tree | 265536975cf9a99ccec70d7d5ad5fea25fdde432 /packages/ExternalStorageProvider | |
parent | 48c52bea8b8b53e9e7d5e0db409a0ada8bd90d0d (diff) | |
parent | a9ce049db87259e302e2368d2a4a1c11a94fd831 (diff) | |
download | frameworks_base-89dec7e6e9ab98141de89096ef052cb2c158c557.zip frameworks_base-89dec7e6e9ab98141de89096ef052cb2c158c557.tar.gz frameworks_base-89dec7e6e9ab98141de89096ef052cb2c158c557.tar.bz2 |
am a9ce049d: Load RootInfo in background, invalidation.
* commit 'a9ce049db87259e302e2368d2a4a1c11a94fd831':
Load RootInfo in background, invalidation.
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; |