Merge "Fix cleanup when an app with SUSPEND_APPS is deleted" into rvc-dev am: 118790bb0e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12002736 Change-Id: Ifea13af51f964bd97ed73e979789657c12865379
This commit is contained in:
@@ -19165,9 +19165,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
final boolean systemApp = isSystemApp(ps);
|
final boolean systemApp = isSystemApp(ps);
|
||||||
|
|
||||||
final int userId = user == null ? UserHandle.USER_ALL : user.getIdentifier();
|
final int userId = user == null ? UserHandle.USER_ALL : user.getIdentifier();
|
||||||
if (ps.getPermissionsState().hasPermission(Manifest.permission.SUSPEND_APPS, userId)) {
|
|
||||||
unsuspendForSuspendingPackage(packageName, userId);
|
|
||||||
}
|
|
||||||
if ((!systemApp || (flags & PackageManager.DELETE_SYSTEM_APP) != 0)
|
if ((!systemApp || (flags & PackageManager.DELETE_SYSTEM_APP) != 0)
|
||||||
&& userId != UserHandle.USER_ALL) {
|
&& userId != UserHandle.USER_ALL) {
|
||||||
// The caller is asking that the package only be deleted for a single
|
// The caller is asking that the package only be deleted for a single
|
||||||
@@ -19225,6 +19223,20 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
outInfo, writeSettings);
|
outInfo, writeSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the package removed had SUSPEND_APPS, unset any restrictions that might have been in
|
||||||
|
// place for all affected users.
|
||||||
|
int[] affectedUserIds = (outInfo != null) ? outInfo.removedUsers : null;
|
||||||
|
if (affectedUserIds == null) {
|
||||||
|
affectedUserIds = resolveUserIds(userId);
|
||||||
|
}
|
||||||
|
for (final int affectedUserId : affectedUserIds) {
|
||||||
|
if (ps.getPermissionsState().hasPermission(Manifest.permission.SUSPEND_APPS,
|
||||||
|
affectedUserId)) {
|
||||||
|
unsuspendForSuspendingPackage(packageName, affectedUserId);
|
||||||
|
removeAllDistractingPackageRestrictions(affectedUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Take a note whether we deleted the package for all users
|
// Take a note whether we deleted the package for all users
|
||||||
if (outInfo != null) {
|
if (outInfo != null) {
|
||||||
outInfo.removedForAllUsers = mPackages.get(ps.name) == null;
|
outInfo.removedForAllUsers = mPackages.get(ps.name) == null;
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ import java.util.Base64;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -291,7 +290,8 @@ class PackageManagerShellCommand extends ShellCommand {
|
|||||||
case "get-stagedsessions":
|
case "get-stagedsessions":
|
||||||
return runListStagedSessions();
|
return runListStagedSessions();
|
||||||
case "uninstall-system-updates":
|
case "uninstall-system-updates":
|
||||||
return uninstallSystemUpdates();
|
String packageName = getNextArg();
|
||||||
|
return uninstallSystemUpdates(packageName);
|
||||||
case "rollback-app":
|
case "rollback-app":
|
||||||
return runRollbackApp();
|
return runRollbackApp();
|
||||||
case "get-moduleinfo":
|
case "get-moduleinfo":
|
||||||
@@ -409,15 +409,22 @@ class PackageManagerShellCommand extends ShellCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int uninstallSystemUpdates() {
|
private int uninstallSystemUpdates(String packageName) {
|
||||||
final PrintWriter pw = getOutPrintWriter();
|
final PrintWriter pw = getOutPrintWriter();
|
||||||
List<String> failedUninstalls = new LinkedList<>();
|
boolean failedUninstalls = false;
|
||||||
try {
|
try {
|
||||||
final ParceledListSlice<ApplicationInfo> packages =
|
|
||||||
mInterface.getInstalledApplications(
|
|
||||||
PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM);
|
|
||||||
final IPackageInstaller installer = mInterface.getPackageInstaller();
|
final IPackageInstaller installer = mInterface.getPackageInstaller();
|
||||||
List<ApplicationInfo> list = packages.getList();
|
final List<ApplicationInfo> list;
|
||||||
|
if (packageName == null) {
|
||||||
|
final ParceledListSlice<ApplicationInfo> packages =
|
||||||
|
mInterface.getInstalledApplications(
|
||||||
|
PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM);
|
||||||
|
list = packages.getList();
|
||||||
|
} else {
|
||||||
|
list = new ArrayList<>(1);
|
||||||
|
list.add(mInterface.getApplicationInfo(packageName,
|
||||||
|
PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM));
|
||||||
|
}
|
||||||
for (ApplicationInfo info : list) {
|
for (ApplicationInfo info : list) {
|
||||||
if (info.isUpdatedSystemApp()) {
|
if (info.isUpdatedSystemApp()) {
|
||||||
pw.println("Uninstalling updates to " + info.packageName + "...");
|
pw.println("Uninstalling updates to " + info.packageName + "...");
|
||||||
@@ -430,7 +437,8 @@ class PackageManagerShellCommand extends ShellCommand {
|
|||||||
final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
|
final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
|
||||||
PackageInstaller.STATUS_FAILURE);
|
PackageInstaller.STATUS_FAILURE);
|
||||||
if (status != PackageInstaller.STATUS_SUCCESS) {
|
if (status != PackageInstaller.STATUS_SUCCESS) {
|
||||||
failedUninstalls.add(info.packageName);
|
failedUninstalls = true;
|
||||||
|
pw.println("Couldn't uninstall package: " + info.packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,10 +448,7 @@ class PackageManagerShellCommand extends ShellCommand {
|
|||||||
+ e.getMessage() + "]");
|
+ e.getMessage() + "]");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!failedUninstalls.isEmpty()) {
|
if (failedUninstalls) {
|
||||||
pw.println("Failure [Couldn't uninstall packages: "
|
|
||||||
+ TextUtils.join(", ", failedUninstalls)
|
|
||||||
+ "]");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pw.println("Success");
|
pw.println("Success");
|
||||||
@@ -3824,9 +3829,10 @@ class PackageManagerShellCommand extends ShellCommand {
|
|||||||
pw.println(" get-harmful-app-warning [--user <USER_ID>] <PACKAGE>");
|
pw.println(" get-harmful-app-warning [--user <USER_ID>] <PACKAGE>");
|
||||||
pw.println(" Return the harmful app warning message for the given app, if present");
|
pw.println(" Return the harmful app warning message for the given app, if present");
|
||||||
pw.println();
|
pw.println();
|
||||||
pw.println(" uninstall-system-updates");
|
pw.println(" uninstall-system-updates [<PACKAGE>]");
|
||||||
pw.println(" Remove updates to all system applications and fall back to their /system " +
|
pw.println(" Removes updates to the given system application and falls back to its");
|
||||||
"version.");
|
pw.println(" /system version. Does nothing if the given package is not a system app.");
|
||||||
|
pw.println(" If no package is specified, removes updates to all system applications.");
|
||||||
pw.println("");
|
pw.println("");
|
||||||
pw.println(" get-moduleinfo [--all | --installed] [module-name]");
|
pw.println(" get-moduleinfo [--all | --installed] [module-name]");
|
||||||
pw.println(" Displays module info. If module-name is specified only that info is shown");
|
pw.println(" Displays module info. If module-name is specified only that info is shown");
|
||||||
|
|||||||
Reference in New Issue
Block a user