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

Commit 631f6a1b authored by JW Wang's avatar JW Wang
Browse files

Protect accesses to mParentSessionId (8/n)

Bug: 159663586
Test: atest StagedInstallTest AtomicInstallTest
Change-Id: I89acee96601d9baf7ec7efd83d63b2d6c67bb8c3
parent 807f59eb
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -1115,7 +1115,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        if (hasParentSessionId()) {
            throw new IllegalStateException(
                    "Session " + sessionId + " is a child of multi-package session "
                            + mParentSessionId +  " and may not be committed directly.");
                            + getParentSessionId() +  " and may not be committed directly.");
        }

        if (!markAsSealed(statusReceiver, forTransfer)) {
@@ -2622,7 +2622,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        if (hasParentSessionId()) {
            throw new IllegalStateException(
                    "Session " + sessionId + " is a child of multi-package session "
                            + mParentSessionId +  " and may not be abandoned directly.");
                            + getParentSessionId() +  " and may not be abandoned directly.");
        }

        List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
@@ -2848,7 +2848,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                            }
                            if (hasParentSessionId()) {
                                mSessionProvider.getSession(
                                        mParentSessionId).dispatchStreamValidateAndCommit();
                                        getParentSessionId()).dispatchStreamValidateAndCommit();
                            } else {
                                dispatchStreamValidateAndCommit();
                            }
@@ -3030,13 +3030,17 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    }

    boolean hasParentSessionId() {
        synchronized (mLock) {
            return mParentSessionId != SessionInfo.INVALID_ID;
        }
    }

    @Override
    public int getParentSessionId() {
        synchronized (mLock) {
            return mParentSessionId;
        }
    }

    private void dispatchSessionFinished(int returnCode, String msg, Bundle extras) {
        final IntentSender statusReceiver;