From 04bdf998e42e9896ee823e84ab5d4293d298328e Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 5 Oct 2021 16:07:02 +0800 Subject: [PATCH] Early detection of mis-configuration (1/n) Move the check to addChildSessionId() to reject the error as early as possible. Bug: 203026561 Test: will be added to CtsAtomicInstallTestCases Change-Id: I30a6161d8ae5a15c270793c80280247b5ae55fa5 --- .../android/server/pm/PackageInstallerSession.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index 020c23d902be9..38059772cfd1a 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -2406,13 +2406,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { final VerificationParams verifyingSession = prepareForVerification(); if (isMultiPackage()) { final List childSessions = getChildSessions(); - // Spot check to reject a non-staged multi package install of APEXes and APKs. - if (!params.isStaged && containsApkSession() - && sessionContains(s -> s.isApexSession())) { - throw new PackageManagerException( - PackageManager.INSTALL_FAILED_SESSION_INVALID, - "Non-staged multi package install of APEX and APK packages is not supported"); - } List verifyingChildSessions = new ArrayList<>(childSessions.size()); boolean success = true; @@ -4172,6 +4165,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { + childSession.sessionId + " and session " + sessionId + " have inconsistent rollback settings"); } + boolean hasAPK = containsApkSession() || !childSession.isApexSession(); + boolean hasAPEX = sessionContains(s -> s.isApexSession()) || childSession.isApexSession(); + if (!params.isStaged && hasAPK && hasAPEX) { + throw new IllegalStateException("Mix of APK and APEX is not supported for " + + "non-staged multi-package session"); + } try { acquireTransactionLock();