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

Commit 9635fbd7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "handle case where user == USER_ALL"

parents 1e92e7fb 6de3d56a
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -15919,14 +15919,6 @@ public class PackageManagerService extends IPackageManager.Stub {
            final PackageSetting ps = mSettings.mPackages.get(pkgName);
            // don't allow an upgrade from full to ephemeral
            if (isInstantApp && !ps.getInstantApp(user.getIdentifier())) {
                // can't downgrade from full to instant
                Slog.w(TAG, "Can't replace app with instant app: " + pkgName);
                res.setReturnCode(PackageManager.INSTALL_FAILED_INSTANT_APP_INVALID);
                return;
            }
            // verify signatures are valid
            if (shouldCheckUpgradeKeySetLP(ps, scanFlags)) {
                if (!checkUpgradeKeySetLP(ps, pkg)) {
@@ -15984,6 +15976,27 @@ public class PackageManagerService extends IPackageManager.Stub {
            // In case of rollback, remember per-user/profile install state
            allUsers = sUserManager.getUserIds();
            installedUsers = ps.queryInstalledUsers(allUsers, true);
            // don't allow an upgrade from full to ephemeral
            if (isInstantApp) {
                if (user == null || user.getIdentifier() == UserHandle.USER_ALL) {
                    for (int currentUser : allUsers) {
                        if (!ps.getInstantApp(currentUser)) {
                            // can't downgrade from full to instant
                            Slog.w(TAG, "Can't replace full app with instant app: " + pkgName
                                    + " for user: " + currentUser);
                            res.setReturnCode(PackageManager.INSTALL_FAILED_INSTANT_APP_INVALID);
                            return;
                        }
                    }
                } else if (!ps.getInstantApp(user.getIdentifier())) {
                    // can't downgrade from full to instant
                    Slog.w(TAG, "Can't replace full app with instant app: " + pkgName
                            + " for user: " + user.getIdentifier());
                    res.setReturnCode(PackageManager.INSTALL_FAILED_INSTANT_APP_INVALID);
                    return;
                }
            }
        }
        // Update what is removed