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

Commit 8219a25e authored by Kenny Guy's avatar Kenny Guy Committed by Android (Google) Code Review
Browse files

Merge "Enforce block uninstall in PackageManager"

parents 4dd9df58 1b88da54
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -841,8 +841,9 @@ public abstract class PackageManager {
    public static final int DELETE_FAILED_USER_RESTRICTED = -3;

    /**
     * Deletion failed return code: this is returned from the PackageInstaller
     * activity if it failed to delete a package because the a profile
     * Deletion failed return code: this is passed to the
     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
     * failed to delete the package because a profile
     * or device owner has marked the package as uninstallable.
     *
     * @hide
+20 −0
Original line number Diff line number Diff line
@@ -10489,6 +10489,26 @@ public class PackageManagerService extends IPackageManager.Stub {
            return;
        }
        boolean blocked = false;
        if ((flags & PackageManager.DELETE_ALL_USERS) != 0) {
            int[] users = sUserManager.getUserIds();
            for (int i = 0; i < users.length; ++i) {
                if (getBlockUninstallForUser(packageName, users[i])) {
                    blocked = true;
                    break;
                }
            }
        } else {
            blocked = getBlockUninstallForUser(packageName, userId);
        }
        if (blocked) {
            try {
                observer.packageDeleted(packageName, PackageManager.DELETE_FAILED_OWNER_BLOCKED);
            } catch (RemoteException re) {
            }
            return;
        }
        if (DEBUG_REMOVE) Slog.d(TAG, "deletePackageAsUser: pkg=" + packageName + " user=" + userId);
        // Queue up an async operation since the package deletion may take a little while.
        mHandler.post(new Runnable() {