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

Commit 048c09f3 authored by Rhed Jao's avatar Rhed Jao
Browse files

Fix incorrect usage of the isInstantApp

The #isInstantApp return true only if called by itself or by
somebody who can view instant apps or by somebody has has
been granted with access. Using the isInstantAppInternal with
system uid to bypass the visibility checks for the caller if
it is not neccessary in the function.

Bug: 203500958
Test: atest EphemeralTest
Test: atest InstantAppUserTest
Test: atest InstantAppTest
Test: atest PackageManagerTest
Change-Id: I48ead977bb125901832f387974a3679e20c6168d
parent 6e441b98
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -798,7 +798,8 @@ public class ComputerEngine implements Computer {
        for (int n = 0; n < count; n++) {
            ResolveInfo info = candidates.get(n);
            if (blockInstant && (info.isInstantAppAvailable
                    || isInstantApp(info.activityInfo.packageName, userId))) {
                    || isInstantAppInternal(info.activityInfo.packageName, userId,
                            Process.SYSTEM_UID))) {
                continue;
            }

@@ -1075,7 +1076,8 @@ public class ComputerEngine implements Computer {
                    resolveInfos.remove(i);
                    continue;
                }
                if (blockInstant && isInstantApp(info.activityInfo.packageName, userId)) {
                if (blockInstant && isInstantAppInternal(
                        info.activityInfo.packageName, userId, Process.SYSTEM_UID)) {
                    resolveInfos.remove(i);
                    continue;
                }
+6 −4
Original line number Diff line number Diff line
@@ -4982,7 +4982,8 @@ public class PackageManagerService extends IPackageManager.Stub
    public void reconcileSecondaryDexFiles(String packageName) {
        if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
            return;
        } else if (isInstantApp(packageName, UserHandle.getCallingUserId())) {
        } else if (isInstantAppInternal(
                packageName, UserHandle.getCallingUserId(), Process.SYSTEM_UID)) {
            return;
        }
        mDexManager.reconcileSecondaryDexFiles(packageName);
@@ -6597,7 +6598,8 @@ public class PackageManagerService extends IPackageManager.Stub
            if (DEBUG_BACKUP) {
                Slog.i(TAG, "Package " + packageName + " sending normal FIRST_LAUNCH");
            }
            final boolean isInstantApp = isInstantApp(packageName, userId);
            final boolean isInstantApp = isInstantAppInternal(
                    packageName, userId, Process.SYSTEM_UID);
            final int[] userIds = isInstantApp ? EMPTY_INT_ARRAY : new int[] { userId };
            final int[] instantUserIds = isInstantApp ? new int[] { userId } : EMPTY_INT_ARRAY;
            mBroadcastHelper.sendFirstLaunchBroadcast(
@@ -7992,7 +7994,7 @@ public class PackageManagerService extends IPackageManager.Stub
    void sendPackageChangedBroadcast(String packageName,
            boolean dontKillApp, ArrayList<String> componentNames, int packageUid, String reason) {
        final int userId = UserHandle.getUserId(packageUid);
        final boolean isInstantApp = isInstantApp(packageName, userId);
        final boolean isInstantApp = isInstantAppInternal(packageName, userId, Process.SYSTEM_UID);
        final int[] userIds = isInstantApp ? EMPTY_INT_ARRAY : new int[] { userId };
        final int[] instantUserIds = isInstantApp ? new int[] { userId } : EMPTY_INT_ARRAY;
        final SparseArray<int[]> broadcastAllowList = getBroadcastAllowList(
@@ -10340,7 +10342,7 @@ public class PackageManagerService extends IPackageManager.Stub
            throw new SecurityException(
                    "Caller uid " + callingUid + " does not own package " + packageName);
        }
        if (isInstantAppInternal(packageName, userId, callingUid)) {
        if (isInstantAppInternal(packageName, userId, Process.SYSTEM_UID)) {
            return false;
        }
        final AndroidPackage pkg;