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

Commit 767bee58 authored by Joanne Chung's avatar Joanne Chung Committed by Automerger Merge Worker
Browse files

Merge "Allow update owner to access InstallConstraints APIs" into udc-dev am: 08d9484b

parents 4e497f7e 08d9484b
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -104,6 +104,7 @@ import com.android.server.SystemConfig;
import com.android.server.SystemService;
import com.android.server.SystemService;
import com.android.server.SystemServiceManager;
import com.android.server.SystemServiceManager;
import com.android.server.pm.parsing.PackageParser2;
import com.android.server.pm.parsing.PackageParser2;
import com.android.server.pm.pkg.PackageStateInternal;
import com.android.server.pm.utils.RequestThrottle;
import com.android.server.pm.utils.RequestThrottle;


import libcore.io.IoUtils;
import libcore.io.IoUtils;
@@ -1308,6 +1309,13 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        }
        }
    }
    }


    private boolean isValidForInstallConstraints(PackageStateInternal ps,
            String installerPackageName) {
        return TextUtils.equals(ps.getInstallSource().mInstallerPackageName, installerPackageName)
                || TextUtils.equals(ps.getInstallSource().mUpdateOwnerPackageName,
                installerPackageName);
    }

    private CompletableFuture<InstallConstraintsResult> checkInstallConstraintsInternal(
    private CompletableFuture<InstallConstraintsResult> checkInstallConstraintsInternal(
            String installerPackageName, List<String> packageNames,
            String installerPackageName, List<String> packageNames,
            InstallConstraints constraints, long timeoutMillis) {
            InstallConstraints constraints, long timeoutMillis) {
@@ -1324,8 +1332,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        if (!PackageManagerServiceUtils.isSystemOrRootOrShell(callingUid)) {
        if (!PackageManagerServiceUtils.isSystemOrRootOrShell(callingUid)) {
            for (var packageName : packageNames) {
            for (var packageName : packageNames) {
                var ps = snapshot.getPackageStateInternal(packageName);
                var ps = snapshot.getPackageStateInternal(packageName);
                if (ps == null || !TextUtils.equals(
                if (ps == null || !isValidForInstallConstraints(ps, installerPackageName)) {
                        ps.getInstallSource().mInstallerPackageName, installerPackageName)) {
                    throw new SecurityException("Caller has no access to package " + packageName);
                    throw new SecurityException("Caller has no access to package " + packageName);
                }
                }
            }
            }