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

Commit 5a032c33 authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "Specifically block suspending the package verifier." into nyc-dev

parents 848727cd ab5ba2ef
Loading
Loading
Loading
Loading
+23 −7
Original line number Original line Diff line number Diff line
@@ -10822,25 +10822,41 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
        }
    }
    }
    // TODO: investigate and add more restrictions for suspending crucial packages.
    /**
     * TODO: cache and disallow blocking the active dialer.
     *
     * @see also DefaultPermissionGrantPolicy#grantDefaultSystemHandlerPermissions
     */
    private boolean canSuspendPackageForUserLocked(String packageName, int userId) {
    private boolean canSuspendPackageForUserLocked(String packageName, int userId) {
        if (isPackageDeviceAdmin(packageName, userId)) {
        if (isPackageDeviceAdmin(packageName, userId)) {
            Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName
            Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
                    + "\": has active device admin");
                    + "\": has an active device admin");
            return false;
            return false;
        }
        }
        String activeLauncherPackageName = getActiveLauncherPackageName(userId);
        String activeLauncherPackageName = getActiveLauncherPackageName(userId);
        if (packageName.equals(activeLauncherPackageName)) {
        if (packageName.equals(activeLauncherPackageName)) {
            Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName
            Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
                    + "\" because it is set as the active launcher");
                    + "\": contains the active launcher");
            return false;
        }
        if (packageName.equals(mRequiredInstallerPackage)) {
            Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
                    + "\": required for package installation");
            return false;
        }
        if (packageName.equals(mRequiredVerifierPackage)) {
            Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
                    + "\": required for package verification");
            return false;
            return false;
        }
        }
        final PackageParser.Package pkg = mPackages.get(packageName);
        final PackageParser.Package pkg = mPackages.get(packageName);
        if (pkg != null && isPrivilegedApp(pkg)) {
        if (pkg != null && isPrivilegedApp(pkg)) {
            Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName
            Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
                    + "\" because it is a privileged app");
                    + "\": is a privileged app");
            return false;
            return false;
        }
        }