Don't enable rollback again in pre-reboot verification

See b/167645815#comment1 for details.

1. In notifyStagedSession(), rollback is enabled for the 1st time.
2. In verifyStagedSession(), rollback is enabled again and
   FileAlreadyExistsException is thrown.

Remove the INSTALL_ENABLE_ROLLBACK flag if the verification is kicked
off by a staged install.

Bug: 167645815
Test: atest RollbackManagerHostTest#testApkOnlyMultipleStagedPartialRollback
      and check logcat messages that no FileAlreadyExistsException is thrown
Change-Id: Id8a96a1dd790331170e2a7e201634b23d20424c6
This commit is contained in:
JW Wang
2020-09-17 10:54:43 +08:00
parent a44e3df0c9
commit ae0c65a7ca

View File

@@ -2080,7 +2080,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
mRelinquished = true;
return mPm.new VerificationParams(user, stageDir, localObserver, params,
// TODO(b/169375643): Remove this workaround once b/161121612 is fixed.
PackageInstaller.SessionParams copiedParams = params.copy();
if (params.isStaged) {
// This is called by the pre-reboot verification. Don't enable rollback here since
// it has been enabled when pre-reboot verification starts.
copiedParams.installFlags &= ~PackageManager.INSTALL_ENABLE_ROLLBACK;
}
return mPm.new VerificationParams(user, stageDir, localObserver, copiedParams,
mInstallSource, mInstallerUid, mSigningDetails, sessionId);
}