summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Richard Uhler <ruhler@google.com> 2019-04-16 10:30:07 +0100
committer Richard Uhler <ruhler@google.com> 2019-04-17 13:59:13 +0100
commitd6f83bb511e630453bd7390c2f8b129811394723 (patch)
tree8c4131eea907a2d921f98a6df36418f11df21ecb
parent6243f0aa27ee1c0f589489ab386d375afacfe2c3 (diff)
Use USER_SYSTEM instead of USER_ALL when enabling rollback.
The rollback manager needs to know the user that the install session is associated with. When installing a package for USER_ALL, the install session is associated with USER_SYSTEM. This fixes an IllegalArgumentException that would otherwise be thrown if we ask for all the sessions associated with USER_ALL. Bug: 130530159 Test: adb install RollbackTestAppAv1.apk adb install -i com.android.shell --enable-rollback RollbackTestAppAv2.apk, run from both primary and secondary users. Change-Id: I4a778ffb96cd79875a54da9de9d348d4744a7efb
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index c1587dc9f86f..ee8c4be84c04 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -14608,6 +14608,20 @@ public class PackageManagerService extends IPackageManager.Stub
return mUser;
}
+ /**
+ * Gets the user handle for the user that the rollback agent should
+ * use to look up information about this installation when enabling
+ * rollback.
+ */
+ UserHandle getRollbackUser() {
+ // The session for packages installed for "all" users is
+ // associated with the "system" user.
+ if (mUser == UserHandle.ALL) {
+ return UserHandle.SYSTEM;
+ }
+ return mUser;
+ }
+
HandlerParams setTraceMethod(String traceMethod) {
this.traceMethod = traceMethod;
return this;
@@ -15226,7 +15240,7 @@ public class PackageManagerService extends IPackageManager.Stub
installedUsers);
enableRollbackIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_USER,
- getUser().getIdentifier());
+ getRollbackUser().getIdentifier());
enableRollbackIntent.setDataAndType(Uri.fromFile(new File(origin.resolvedPath)),
PACKAGE_MIME_TYPE);
enableRollbackIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);