Move build fingerprint check outside of main loop

Per discussion in ag/9915756, call PM.isDeviceUpgrading once
outside of the main loop when restoring staged sessions.

Test: atest StagedInstallTest#testInstallApkChangingFingerprint
Bug: 140992644
Change-Id: I65ac48e49364706857670dee96e47584c3a19295
This commit is contained in:
Gavin Corkery
2019-12-17 22:36:56 +00:00
parent b8edc67908
commit ede47c927e

View File

@@ -257,8 +257,9 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
}
// Don't hold mSessions lock when calling restoreSession, since it might trigger an APK
// atomic install which needs to query sessions, which requires lock on mSessions.
boolean isDeviceUpgrading = mPm.isDeviceUpgrading();
for (PackageInstallerSession session : stagedSessionsToRestore) {
if (mPm.isDeviceUpgrading() && !session.isStagedAndInTerminalState()) {
if (isDeviceUpgrading && !session.isStagedAndInTerminalState()) {
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
"Build fingerprint has changed");
}