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

Commit 10f0195f authored by Rhed Jao's avatar Rhed Jao
Browse files

Enforce package visibility filter on the PreferredActivities

A security fix to enforce package visibility filter on the api of
PackageManager#getPreferredActivities.

Bug: 188218313
Test: atest AppEnumerationTests
Change-Id: I73e2385ee51e1921dc1abe4292a66a4d9a7f15ed
parent 018e1142
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -22120,7 +22120,8 @@ public class PackageManagerService extends IPackageManager.Stub
     */
    public int getPreferredActivitiesInternal(List<WatchedIntentFilter> outFilters,
            List<ComponentName> outActivities, String packageName) {
        if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
        final int callingUid = Binder.getCallingUid();
        if (getInstantAppPackageName(callingUid) != null) {
            return 0;
        }
        int num = 0;
@@ -22132,9 +22133,13 @@ public class PackageManagerService extends IPackageManager.Stub
                final Iterator<PreferredActivity> it = pir.filterIterator();
                while (it.hasNext()) {
                    final PreferredActivity pa = it.next();
                    final String prefPackageName = pa.mPref.mComponent.getPackageName();
                    if (packageName == null
                            || (pa.mPref.mComponent.getPackageName().equals(packageName)
                                    && pa.mPref.mAlways)) {
                            || (prefPackageName.equals(packageName) && pa.mPref.mAlways)) {
                        if (shouldFilterApplicationLocked(
                                mSettings.getPackageLPr(prefPackageName), callingUid, userId)) {
                            continue;
                        }
                        if (outFilters != null) {
                            outFilters.add(new WatchedIntentFilter(pa.getIntentFilter()));
                        }