Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d75c67a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix crash when DocumentsProviders using duplicate authority exist" into pi-dev

parents 4f8fa7a7 939d0188
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -241,8 +241,13 @@ public class ProvidersCache implements ProvidersAccess {
        if (VERBOSE) Log.v(TAG, "Loading roots for " + authority);

        final ArrayList<RootInfo> roots = new ArrayList<>();
        ProviderInfo provider = mContext.getPackageManager().resolveContentProvider(
        final PackageManager pm = mContext.getPackageManager();
        ProviderInfo provider = pm.resolveContentProvider(
                authority, PackageManager.GET_META_DATA);
        if (provider == null) {
            Log.w(TAG, "Failed to get provider info for " + authority);
            return roots;
        }
        if (!provider.exported) {
            Log.w(TAG, "Provider is not exported. Failed to load roots for " + authority);
            return roots;
@@ -261,7 +266,6 @@ public class ProvidersCache implements ProvidersAccess {

        synchronized (mObservedAuthoritiesDetails) {
            if (!mObservedAuthoritiesDetails.containsKey(authority)) {
                PackageManager pm = mContext.getPackageManager();
                CharSequence appName = pm.getApplicationLabel(provider.applicationInfo);
                String packageName = provider.applicationInfo.packageName;

@@ -460,7 +464,10 @@ public class ProvidersCache implements ProvidersAccess {
            final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
            final List<ResolveInfo> providers = pm.queryIntentContentProviders(intent, 0);
            for (ResolveInfo info : providers) {
                handleDocumentsProvider(info.providerInfo);
                ProviderInfo providerInfo = info.providerInfo;
                if (providerInfo.authority != null) {
                    handleDocumentsProvider(providerInfo);
                }
            }

            final long delta = SystemClock.elapsedRealtime() - start;