Allow staging multi-package session immediately after abandonment

When we stage a session, we compare it with other already staged
sessions to detect overlap. We do not allow a session to stage if it
contains a package which is already staged in another session.

Due to a bug, while comparing we were not excluding sessions whose
parents were abandoned already. This CL fixes that.

Bug: 159409632
Test: atest
StagedInstallTest#testStageAnotherSessionImmediatelyAfterAbandonMultiPackage

Change-Id: I740986af666b3d2d8ab832c4bcdb855c1ed3c16f
This commit is contained in:
Mohammad Samiul Islam
2020-06-19 13:26:34 +01:00
parent 1f6b99d5fa
commit 806ccabb73

View File

@@ -969,19 +969,19 @@ public class StagingManager {
// name and the session we are checking is not a parent session either.
continue;
}
// From here on, stagedSession is a non-parent active staged session
// Check if stagedSession has an active parent session or not
if (stagedSession.hasParentSessionId()) {
int parentId = stagedSession.getParentSessionId();
PackageInstallerSession parentSession = mStagedSessions.get(parentId);
if (parentSession == null || parentSession.isStagedAndInTerminalState()) {
if (parentSession == null || parentSession.isStagedAndInTerminalState()
|| parentSession.isDestroyed()) {
// Parent session has been abandoned or terminated already
continue;
}
}
// From here on, stagedSession is a non-parent active staged session
// Check if session is one of the active sessions
if (session.sessionId == stagedSession.sessionId) {
Slog.w(TAG, "Session " + session.sessionId + " is already staged");