Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1d2b9dc authored by JW Wang's avatar JW Wang
Browse files

Fix #removeChildSessionId (4/n)

Removing a non-owning child should be no-op.
The current implementation will set the parent id to -1 incorrectly.

Bug: 162286562
Test: Will be added in next CLs
Change-Id: I483c570079511d5f10dcfdc93e7daf006004b226
parent 40fc1cde
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3143,14 +3143,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            synchronized (mLock) {
                assertCallerIsOwnerOrRootLocked();
                assertPreparedAndNotSealedLocked("removeChildSessionId");

                final int indexOfSession = mChildSessionIds.indexOfKey(sessionId);
                if (session != null) {
                    session.setParentSessionId(SessionInfo.INVALID_ID);
                }
                if (indexOfSession < 0) {
                    // not added in the first place; no-op
                    return;
                }
                if (session != null) {
                    session.setParentSessionId(SessionInfo.INVALID_ID);
                }
                mChildSessionIds.removeAt(indexOfSession);
            }
        } finally {