From 6de494dfb36ba5677996c844198210fe392a1ba7 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Tue, 5 Sep 2017 10:59:03 -0700 Subject: [PATCH] resolve stage dir before validation We rely on the stage directory being correctly resolved in order for validation to occur. This forcably happens when commiting [after validation], reading or writing to the session. For normal installs, this isn't an issue since the session will be written to, thus, resolving the stage directory. Instead of waiting until the commit, resolve the stage directory just prior to package validation. Change-Id: I667b9d27749405d24e3a3c6666e9591ce3e883df Fixes: 65369970 Test: bit FrameworksCoreTests:android.content.pm.PackageManagerTests\#testInstallNonexistentFile --- .../android/server/pm/PackageInstallerSession.java | 14 +++++++------- 1 file changed, 7 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 871ed5c7dbad6..fddbd670d1a22 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -807,13 +807,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { throw new PackageManagerException(INSTALL_FAILED_INTERNAL_ERROR, "Session not sealed"); } - try { - resolveStageDirLocked(); - } catch (IOException e) { - throw new PackageManagerException(INSTALL_FAILED_CONTAINER_ERROR, - "Failed to resolve stage location", e); - } - Preconditions.checkNotNull(mPackageName); Preconditions.checkNotNull(mSignatures); Preconditions.checkNotNull(mResolvedBaseFile); @@ -934,6 +927,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { mResolvedStagedFiles.clear(); mResolvedInheritedFiles.clear(); + try { + resolveStageDirLocked(); + } catch (IOException e) { + throw new PackageManagerException(INSTALL_FAILED_CONTAINER_ERROR, + "Failed to resolve stage location", e); + } + final File[] removedFiles = mResolvedStageDir.listFiles(sRemovedFilter); final List removeSplitList = new ArrayList<>(); if (!ArrayUtils.isEmpty(removedFiles)) {