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

Commit 9687767d authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Allow querying providers with a specific metadata."

parents 2a434d17 32757292
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1024,12 +1024,18 @@ public class ApplicationPackageManager extends PackageManager {
    }

    @Override
    @SuppressWarnings("unchecked")
    public List<ProviderInfo> queryContentProviders(String processName,
            int uid, int flags) {
        return queryContentProviders(processName, uid, flags, null);
    }

    @Override
    @SuppressWarnings("unchecked")
    public List<ProviderInfo> queryContentProviders(String processName,
            int uid, int flags, String metaDataKey) {
        try {
            ParceledListSlice<ProviderInfo> slice =
                    mPM.queryContentProviders(processName, uid, flags);
                    mPM.queryContentProviders(processName, uid, flags, metaDataKey);
            return slice != null ? slice.getList() : Collections.<ProviderInfo>emptyList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+1 −1
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ interface IPackageManager {
            inout List<ProviderInfo> outInfo);

    ParceledListSlice queryContentProviders(
            String processName, int uid, int flags);
            String processName, int uid, int flags, String metaDataKey);

    InstrumentationInfo getInstrumentationInfo(
            in ComponentName className, int flags);
+21 −0
Original line number Diff line number Diff line
@@ -4461,6 +4461,27 @@ public abstract class PackageManager {
    public abstract List<ProviderInfo> queryContentProviders(
            String processName, int uid, @ComponentInfoFlags int flags);

    /**
     * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null,
     * it only returns providers which have metadata with the {@code metaDataKey} key.
     *
     * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider.
     * You really shouldn't need it.  Other apps should use {@link #queryIntentContentProviders}
     * instead.
     *
     * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly
     * scan the GAL providers on the device.  Unfortunately the discovery protocol used metadata
     * to mark GAL providers, rather than intent filters, so we can't use
     * {@link #queryIntentContentProviders} for that.
     *
     * @hide
     */
    public List<ProviderInfo> queryContentProviders(
            String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) {
        // Provide the default implementation for mocks.
        return queryContentProviders(processName, uid, flags);
    }

    /**
     * Retrieve all of the information we know about a particular
     * instrumentation class.
+1 −1
Original line number Diff line number Diff line
@@ -10645,7 +10645,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            providers = AppGlobals.getPackageManager()
                    .queryContentProviders(app.processName, app.uid,
                            STOCK_PM_FLAGS | PackageManager.GET_URI_PERMISSION_PATTERNS
                                    | MATCH_DEBUG_TRIAGED_MISSING)
                                    | MATCH_DEBUG_TRIAGED_MISSING, /*metadastaKey=*/ null)
                    .getList();
        } catch (RemoteException ex) {
        }
+9 −1
Original line number Diff line number Diff line
@@ -7469,7 +7469,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    @Override
    public @NonNull ParceledListSlice<ProviderInfo> queryContentProviders(String processName,
            int uid, int flags) {
            int uid, int flags, String metaDataKey) {
        final int userId = processName != null ? UserHandle.getUserId(uid)
                : UserHandle.getCallingUserId();
        if (!sUserManager.exists(userId)) return ParceledListSlice.emptyList();
@@ -7487,6 +7487,14 @@ public class PackageManagerService extends IPackageManager.Stub {
                                || (p.info.processName.equals(processName)
                                        && UserHandle.isSameApp(p.info.applicationInfo.uid, uid)))
                        && mSettings.isEnabledAndMatchLPr(p.info, flags, userId)) {
                    // See PM.queryContentProviders()'s javadoc for why we have the metaData
                    // parameter.
                    if (metaDataKey != null
                            && (p.metaData == null || !p.metaData.containsKey(metaDataKey))) {
                        continue;
                    }
                    if (finalList == null) {
                        finalList = new ArrayList<ProviderInfo>(3);
                    }