diff options
| author | 2022-11-10 06:00:41 +0000 | |
|---|---|---|
| committer | 2022-11-10 06:00:41 +0000 | |
| commit | 98a754b3826b839f31b41daf87060d571dc19e00 (patch) | |
| tree | 182165f4f74098cda0d86dcd3c29c56fc9aa5efe | |
| parent | 1081331223779f900c9cabd5857d0eaefede5e78 (diff) | |
| parent | 1138064218b9e29c5ab97d58d963946a8c093828 (diff) | |
Merge "Prevent committing session while in progress" into tm-qpr-dev
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageInstallerSession.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index 37bfbb11948a..06458d1bf50c 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -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(); } |