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

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

Merge "Don't grant visibility based on non-exported components"

parents 9319ea66 5863233a
Loading
Loading
Loading
Loading
+44 −19
Original line number Diff line number Diff line
@@ -195,19 +195,19 @@ public class AppsFilter {
            return false;
        }
        for (Intent intent : querying.mQueriesIntents) {
            if (matches(intent, potentialTarget.providers, potentialTarget.activities,
                    potentialTarget.services, potentialTarget.receivers)) {
            if (matches(intent, potentialTarget)) {
                return true;
            }
        }
        return false;
    }

    private static boolean matches(Intent intent,
            ArrayList<PackageParser.Provider> providerList,
            ArrayList<? extends Component<? extends IntentInfo>>... componentLists) {
        for (int p = providerList.size() - 1; p >= 0; p--) {
            PackageParser.Provider provider = providerList.get(p);
    private static boolean matches(Intent intent, PackageParser.Package potentialTarget) {
        for (int p = potentialTarget.providers.size() - 1; p >= 0; p--) {
            PackageParser.Provider provider = potentialTarget.providers.get(p);
            if (!provider.info.exported) {
                continue;
            }
            final ProviderInfo providerInfo = provider.info;
            final Uri data = intent.getData();
            if ("content".equalsIgnoreCase(intent.getScheme())
@@ -216,11 +216,38 @@ public class AppsFilter {
                return true;
            }
        }
        for (int s = potentialTarget.services.size() - 1; s >= 0; s--) {
            PackageParser.Service service = potentialTarget.services.get(s);
            if (!service.info.exported) {
                continue;
            }
            if (matchesAnyFilter(intent, service)) {
                return true;
            }
        }
        for (int a = potentialTarget.activities.size() - 1; a >= 0; a--) {
            PackageParser.Activity activity = potentialTarget.activities.get(a);
            if (!activity.info.exported) {
                continue;
            }
            if (matchesAnyFilter(intent, activity)) {
                return true;
            }
        }
        for (int r = potentialTarget.receivers.size() - 1; r >= 0; r--) {
            PackageParser.Activity receiver = potentialTarget.receivers.get(r);
            if (!receiver.info.exported) {
                continue;
            }
            if (matchesAnyFilter(intent, receiver)) {
                return true;
            }
        }
        return false;
    }

        for (int l = componentLists.length - 1; l >= 0; l--) {
            ArrayList<? extends Component<? extends IntentInfo>> components = componentLists[l];
            for (int c = components.size() - 1; c >= 0; c--) {
                Component<? extends IntentInfo> component = components.get(c);
    private static boolean matchesAnyFilter(
            Intent intent, Component<? extends IntentInfo> component) {
        ArrayList<? extends IntentInfo> intents = component.intents;
        for (int i = intents.size() - 1; i >= 0; i--) {
            IntentFilter intentFilter = intents.get(i);
@@ -229,8 +256,6 @@ public class AppsFilter {
                return true;
            }
        }
            }
        }
        return false;
    }