Merge "Prevent committing session while in progress" into tm-qpr-dev am: 98a754b382

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20394007

Change-Id: I34438e2eb3e4f2407aac46afb24f3ca05c1e2726
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chun-Wei Wang
2022-11-10 08:03:56 +00:00
committed by Automerger Merge Worker

View File

@@ -366,6 +366,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
@GuardedBy("mLock")
private boolean mStageDirInUse = false;
/**
* True if the installation is already in progress. This is used to prevent the caller
* from {@link #commit(IntentSender, boolean) committing} the session again while the
* installation is still in progress.
*/
@GuardedBy("mLock")
private boolean mInstallationInProgress = false;
/** Permissions have been accepted by the user (see {@link #setPermissionsResult}) */
@GuardedBy("mLock")
private boolean mPermissionsManuallyAccepted = false;
@@ -1661,6 +1669,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
}
synchronized (mLock) {
if (mInstallationInProgress) {
throw new IllegalStateException("Installation is already in progress. Don't "
+ "commit session=" + sessionId + " again.");
}
mInstallationInProgress = true;
}
dispatchSessionSealed();
}