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

Commit 1b88da54 authored by Kenny Guy's avatar Kenny Guy
Browse files

Enforce block uninstall in PackageManager

Bug: 14127299
Change-Id: I144233b97e5774f6a5d1d2b49f3f0f8a360557ac
parent c09a04da
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
@@ -10308,6 +10308,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() {