summaryrefslogtreecommitdiffstats
path: root/packages/DocumentsUI
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-10-07 14:44:52 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-07 14:44:52 -0700
commit5e02e0a9e1e075e3d451d929b0a67bf280c432ed (patch)
treebf7091673086b11a7a2b5d9f0da75031d327294c /packages/DocumentsUI
parent73c3c65b1bb05754c688a76a1dbc79c0120c0915 (diff)
parentbcc77b502b56d4b91610adfa10c657003c9c820d (diff)
downloadframeworks_base-5e02e0a9e1e075e3d451d929b0a67bf280c432ed.zip
frameworks_base-5e02e0a9e1e075e3d451d929b0a67bf280c432ed.tar.gz
frameworks_base-5e02e0a9e1e075e3d451d929b0a67bf280c432ed.tar.bz2
am bcc77b50: Merge "Add <intent-filter> support to <provider>." into klp-dev
* commit 'bcc77b502b56d4b91610adfa10c657003c9c820d': Add <intent-filter> support to <provider>.
Diffstat (limited to 'packages/DocumentsUI')
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/RootsCache.java81
1 files changed, 48 insertions, 33 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
index bad0a96..eb56765 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
@@ -21,9 +21,11 @@ import static com.android.documentsui.DocumentsActivity.TAG;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
+import android.content.pm.ResolveInfo;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
@@ -158,6 +160,9 @@ public class RootsCache {
private class UpdateTask extends AsyncTask<Void, Void, Void> {
private final String mFilterPackage;
+ private final Multimap<String, RootInfo> mTaskRoots = ArrayListMultimap.create();
+ private final HashSet<String> mTaskStoppedAuthorities = Sets.newHashSet();
+
/**
* Update all roots.
*/
@@ -177,54 +182,64 @@ public class RootsCache {
protected Void doInBackground(Void... params) {
final long start = SystemClock.elapsedRealtime();
- final Multimap<String, RootInfo> roots = ArrayListMultimap.create();
- final HashSet<String> stoppedAuthorities = Sets.newHashSet();
-
- roots.put(mRecentsRoot.authority, mRecentsRoot);
+ mTaskRoots.put(mRecentsRoot.authority, mRecentsRoot);
final ContentResolver resolver = mContext.getContentResolver();
final PackageManager pm = mContext.getPackageManager();
- final List<ProviderInfo> providers = pm.queryContentProviders(
+
+ // Pick up provider with action string
+ final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
+ final List<ResolveInfo> providers = pm.queryIntentContentProviders(intent, 0);
+ for (ResolveInfo info : providers) {
+ handleDocumentsProvider(info.providerInfo);
+ }
+
+ // Pick up legacy providers
+ final List<ProviderInfo> legacyProviders = pm.queryContentProviders(
null, -1, PackageManager.GET_META_DATA);
- for (ProviderInfo info : providers) {
+ for (ProviderInfo info : legacyProviders) {
if (info.metaData != null && info.metaData.containsKey(
DocumentsContract.META_DATA_DOCUMENT_PROVIDER)) {
- // Ignore stopped packages for now; we might query them
- // later during UI interaction.
- if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
- if (LOGD) Log.d(TAG, "Ignoring stopped authority " + info.authority);
- stoppedAuthorities.add(info.authority);
- continue;
- }
-
- // Try using cached roots if filtering
- boolean cacheHit = false;
- if (mFilterPackage != null && !mFilterPackage.equals(info.packageName)) {
- synchronized (mLock) {
- if (roots.putAll(info.authority, mRoots.get(info.authority))) {
- if (LOGD) Log.d(TAG, "Used cached roots for " + info.authority);
- cacheHit = true;
- }
- }
- }
-
- // Cache miss, or loading everything
- if (!cacheHit) {
- roots.putAll(
- info.authority, loadRootsForAuthority(resolver, info.authority));
- }
+ handleDocumentsProvider(info);
}
}
final long delta = SystemClock.elapsedRealtime() - start;
- Log.d(TAG, "Update found " + roots.size() + " roots in " + delta + "ms");
+ Log.d(TAG, "Update found " + mTaskRoots.size() + " roots in " + delta + "ms");
synchronized (mLock) {
- mStoppedAuthorities = stoppedAuthorities;
- mRoots = roots;
+ mRoots = mTaskRoots;
+ mStoppedAuthorities = mTaskStoppedAuthorities;
}
mFirstLoad.countDown();
return null;
}
+
+ private void handleDocumentsProvider(ProviderInfo info) {
+ // Ignore stopped packages for now; we might query them
+ // later during UI interaction.
+ if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
+ if (LOGD) Log.d(TAG, "Ignoring stopped authority " + info.authority);
+ mTaskStoppedAuthorities.add(info.authority);
+ return;
+ }
+
+ // Try using cached roots if filtering
+ boolean cacheHit = false;
+ if (mFilterPackage != null && !mFilterPackage.equals(info.packageName)) {
+ synchronized (mLock) {
+ if (mTaskRoots.putAll(info.authority, mRoots.get(info.authority))) {
+ if (LOGD) Log.d(TAG, "Used cached roots for " + info.authority);
+ cacheHit = true;
+ }
+ }
+ }
+
+ // Cache miss, or loading everything
+ if (!cacheHit) {
+ mTaskRoots.putAll(info.authority,
+ loadRootsForAuthority(mContext.getContentResolver(), info.authority));
+ }
+ }
}
/**