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

Commit d5f7e305 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

fix leaky apps

We leak installed app information if either the package or component
are specified in the query intents.

Bug: 25119046
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest
Change-Id: Ide2bc83889cc90bb56b5e13a8c3ddc1ba1901be7
parent 15589c36
Loading
Loading
Loading
Loading
+17 −5
Original line number Original line Diff line number Diff line
@@ -5524,10 +5524,22 @@ public class PackageManagerService extends IPackageManager.Stub {
            final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
            final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
            final ActivityInfo ai = getActivityInfo(comp, flags, userId);
            final ActivityInfo ai = getActivityInfo(comp, flags, userId);
            if (ai != null) {
            if (ai != null) {
                // When specifying an explicit component, we prevent the activity from being
                // used when either 1) the calling package is normal and the activity is within
                // an ephemeral application or 2) the calling package is ephemeral and the
                // activity is not visible to ephemeral applications.
                boolean blockResolution =
                        (ephemeralPkgName == null
                                && (ai.applicationInfo.privateFlags
                                        & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0)
                        || (ephemeralPkgName != null
                                && (ai.flags & ActivityInfo.FLAG_VISIBLE_TO_EPHEMERAL) == 0);
                if (!blockResolution) {
                    final ResolveInfo ri = new ResolveInfo();
                    final ResolveInfo ri = new ResolveInfo();
                    ri.activityInfo = ai;
                    ri.activityInfo = ai;
                    list.add(ri);
                    list.add(ri);
                }
                }
            }
            return list;
            return list;
        }
        }
@@ -5604,10 +5616,10 @@ public class PackageManagerService extends IPackageManager.Stub {
            } else {
            } else {
                final PackageParser.Package pkg = mPackages.get(pkgName);
                final PackageParser.Package pkg = mPackages.get(pkgName);
                if (pkg != null) {
                if (pkg != null) {
                    result = filterIfNotSystemUser(
                    result = filterForEphemeral(filterIfNotSystemUser(
                            mActivities.queryIntentForPackage(
                            mActivities.queryIntentForPackage(
                                    intent, resolvedType, flags, pkg.activities, userId),
                                    intent, resolvedType, flags, pkg.activities, userId),
                            userId);
                            userId), ephemeralPkgName);
                } else {
                } else {
                    // the caller wants to resolve for a particular package; however, there
                    // the caller wants to resolve for a particular package; however, there
                    // were no installed results, so, try to find an ephemeral result
                    // were no installed results, so, try to find an ephemeral result