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
This commit is contained in:
JW Wang
2020-07-28 12:53:29 +08:00
parent 40fc1cde8e
commit b1d2b9dc94

View File

@@ -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 {