Loading services/core/java/com/android/server/pm/PackageManagerService.java +31 −4 Original line number Diff line number Diff line Loading @@ -10678,10 +10678,7 @@ public class PackageManagerService extends IPackageManager.Stub { enforceCrossUserPermission(Binder.getCallingUid(), userId, true, true, "setPackageSuspended for user " + userId); // TODO: investigate and add more restrictions for suspending crucial packages. if (isPackageDeviceAdmin(packageName, userId)) { Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName + "\": has active device admin"); if (!canSuspendPackageForUser(packageName, userId)) { return false; } Loading Loading @@ -10726,6 +10723,36 @@ public class PackageManagerService extends IPackageManager.Stub { } } // TODO: investigate and add more restrictions for suspending crucial packages. private boolean canSuspendPackageForUser(String packageName, int userId) { if (isPackageDeviceAdmin(packageName, userId)) { Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName + "\": has active device admin"); return false; } String activeLauncherPackageName = getActiveLauncherPackageName(userId); if (packageName.equals(activeLauncherPackageName)) { Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName + "\" because it is set as the active launcher"); return false; } return true; } private String getActiveLauncherPackageName(int userId) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); ResolveInfo resolveInfo = resolveIntent( intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.MATCH_DEFAULT_ONLY, userId); return resolveInfo == null ? null : resolveInfo.activityInfo.packageName; } @Override public void verifyPendingInstall(int id, int verificationCode) throws RemoteException { mContext.enforceCallingOrSelfPermission( Loading Loading
services/core/java/com/android/server/pm/PackageManagerService.java +31 −4 Original line number Diff line number Diff line Loading @@ -10678,10 +10678,7 @@ public class PackageManagerService extends IPackageManager.Stub { enforceCrossUserPermission(Binder.getCallingUid(), userId, true, true, "setPackageSuspended for user " + userId); // TODO: investigate and add more restrictions for suspending crucial packages. if (isPackageDeviceAdmin(packageName, userId)) { Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName + "\": has active device admin"); if (!canSuspendPackageForUser(packageName, userId)) { return false; } Loading Loading @@ -10726,6 +10723,36 @@ public class PackageManagerService extends IPackageManager.Stub { } } // TODO: investigate and add more restrictions for suspending crucial packages. private boolean canSuspendPackageForUser(String packageName, int userId) { if (isPackageDeviceAdmin(packageName, userId)) { Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName + "\": has active device admin"); return false; } String activeLauncherPackageName = getActiveLauncherPackageName(userId); if (packageName.equals(activeLauncherPackageName)) { Slog.w(TAG, "Not suspending/un-suspending package \"" + packageName + "\" because it is set as the active launcher"); return false; } return true; } private String getActiveLauncherPackageName(int userId) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); ResolveInfo resolveInfo = resolveIntent( intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.MATCH_DEFAULT_ONLY, userId); return resolveInfo == null ? null : resolveInfo.activityInfo.packageName; } @Override public void verifyPendingInstall(int id, int verificationCode) throws RemoteException { mContext.enforceCallingOrSelfPermission( Loading