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
This commit is contained in:
Todd Kennedy
2017-09-05 10:59:03 -07:00
parent d9abde75e8
commit 6de494dfb3

View File

@@ -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<String> removeSplitList = new ArrayList<>();
if (!ArrayUtils.isEmpty(removedFiles)) {