OSDN Git Service

Use system user when installing APKs.
authorDario Freni <dariofreni@google.com>
Tue, 2 Apr 2019 10:45:13 +0000 (11:45 +0100)
committerDario Freni <dariofreni@google.com>
Tue, 2 Apr 2019 13:27:01 +0000 (14:27 +0100)
For Mainline module updates, this will effectively be the same operation
as installing the packages as a secondary user, since the packages are
preinstalled and preinstalled packages are visible to users. Also,
Mainline modules cannot be disabled per-user.

Since staged install are only issued by privileged apps having
INSTALL_PACKAGES permission, we believe this change is safe for the sake
of mainline.

Fix: 129397974
Bug: 129744602
Test: repro b/129397974 and verify install succeeds.
Change-Id: I5b388707848b6cdbf20511eea02a0c2abd768b86

services/core/java/com/android/server/pm/StagingManager.java

index 190610c..a0f0a31 100644 (file)
@@ -384,8 +384,10 @@ public class StagingManager {
         PackageInstaller.SessionParams params = originalSession.params.copy();
         params.isStaged = false;
         params.installFlags |= PackageManager.INSTALL_DISABLE_VERIFICATION;
+        // TODO(b/129744602): use the userid from the original session.
         int apkSessionId = mPi.createSession(
-                params, originalSession.getInstallerPackageName(), originalSession.userId);
+                params, originalSession.getInstallerPackageName(),
+                0 /* UserHandle.SYSTEM */);
         PackageInstallerSession apkSession = mPi.getSession(apkSessionId);
 
         try {
@@ -465,8 +467,10 @@ public class StagingManager {
             }
             PackageInstaller.SessionParams params = session.params.copy();
             params.isStaged = false;
+            // TODO(b/129744602): use the userid from the original session.
             int apkParentSessionId = mPi.createSession(
-                    params, session.getInstallerPackageName(), session.userId);
+                    params, session.getInstallerPackageName(),
+                    0 /* UserHandle.SYSTEM */);
             PackageInstallerSession apkParentSession = mPi.getSession(apkParentSessionId);
             try {
                 apkParentSession.open();