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

Commit 5863233a authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Don't grant visibility based on non-exported components

This change ensures that unexported components are not considered when
determining visibility between apps.

Fixes: 142382342
Test: atest AppEnumerationTests
Change-Id: I0ef0c3f141d2b8206787f4d39dfe3209b72c0dbb
parent 9d9e19c5
Loading
Loading
Loading
Loading
+44 −19
Original line number Diff line number Diff line
@@ -202,19 +202,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())
@@ -223,11 +223,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);
@@ -236,8 +263,6 @@ public class AppsFilter {
                return true;
            }
        }
            }
        }
        return false;
    }