Prevent interleaved verification

Committing a session twice in a row will result in interleaved
verification flows and break the internal states.

Add a field to prevent this from happening if the verification
is already in progress.

Bug: 256330705
Test: manual test
Change-Id: I7e8a2fa7333d05a226268b325338e3fac69ddae0
This commit is contained in:
JW Wang
2022-11-18 14:37:47 +08:00
committed by Chun-Wei Wang
parent bdc9177efd
commit da7d72d88b

View File

@@ -380,6 +380,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
@GuardedBy("mLock")
private boolean mStageDirInUse = false;
/**
* True if the verification is already in progress. This is used to prevent running
* verification again while one is already in progress which will break internal states.
*
* Worker thread only.
*/
private boolean mVerificationInProgress = false;
/** Permissions have been accepted by the user (see {@link #setPermissionsResult}) */
@GuardedBy("mLock")
private boolean mPermissionsManuallyAccepted = false;
@@ -2201,6 +2209,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
activate();
}
if (mVerificationInProgress) {
Slog.w(TAG, "Verification is already in progress for session " + sessionId);
return;
}
mVerificationInProgress = true;
if (params.isStaged) {
mStagedSession.verifySession();
} else {