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

Commit d6f83bb5 authored by Richard Uhler's avatar Richard Uhler
Browse files

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
parent 6243f0aa
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -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);