[DO NOT MERGE] Prevent extra sessions owned by staged install from living across restarts am: 4d60cca9f7

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

Change-Id: Ief1c57c1541acc3dd8090b5ffde6ec02b2e06d58
This commit is contained in:
Mohammad Samiul Islam
2020-11-03 21:28:34 +00:00
committed by Automerger Merge Worker

View File

@@ -393,6 +393,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
Slog.w(TAG, "Abandoning old session created at "
+ session.createdMillis);
valid = false;
} else if (isExtraSessionForStagedInstall(session)) {
valid = false;
} else {
valid = true;
}
@@ -423,6 +425,13 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
}
}
// Extra sessions are created during staged install on temporary basis. They should not be
// allowed to live across system server restart.
private boolean isExtraSessionForStagedInstall(PackageInstallerSession session) {
return (session.params.installFlags & PackageManager.INSTALL_DRY_RUN) != 0
|| (session.params.installFlags & PackageManager.INSTALL_DISABLE_VERIFICATION) != 0;
}
@GuardedBy("mSessions")
private void addHistoricalSessionLocked(PackageInstallerSession session) {
CharArrayWriter writer = new CharArrayWriter();