static @Nullable ProviderInfo findTargetProvider(final Context context) {
		final PackageManager pm = context.getPackageManager();
		final ProviderInfo provider = pm.resolveContentProvider(TARGET_AUTHORITY, 0);
		final String error_event = "esp_error";
		if (provider != null) {
			if (! provider.exported) Analytics.$().event(error_event).with(ITEM_CATEGORY, "not exported").send();
			else if (! MANAGE_DOCUMENTS.equals(provider.readPermission))
				Analytics.$().event(error_event).with(ITEM_CATEGORY, "permission").with(ITEM_ID, provider.readPermission).send();
			else return provider;
		}

		// In case authority cannot be found, try enumerating documents providers in package of its well-known name. (Fixed authority name is unnecessary for documents provider)
		final List<ResolveInfo> resolves = pm.queryIntentContentProviders(new Intent(PROVIDER_INTERFACE).setPackage(TARGET_PACKAGE), 0);
		if (resolves.isEmpty()) {
			Log.e(TAG, "Documents provider for external storage is missing.");
			return null;
		}
		final ResolveInfo first_resolve = resolves.get(0);
		if (resolves.size() > 1) {
			Log.w(TAG, "Potential providers: " + resolves);
			for (final ResolveInfo resolve : resolves) {
				final String authority = resolve.providerInfo.authority;
				final String info = resolve.toString();
				Analytics.$().event(error_event).with(ITEM_CATEGORY, "indistinguishable").with(ITEM_ID, authority + ":" + info).send();
				Log.w(TAG, ">> " + authority + ": " + info);
			}
		} else Analytics.$().event(error_event).with(ITEM_CATEGORY, "authority").with(ITEM_ID, first_resolve.providerInfo.authority).send();

		return first_resolve.providerInfo;
	}
Documents provider for accessing files in / outside Island.

Created by Oasis on 2017/8/29.
fileprovider/src/main/java/com/oasisfeng/island/fileprovider/ExternalStorageProviderProxy.java