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

Commit f46edf5b authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Allow to close session from wrong context.

commitLocked runs on a handler, thereby as system. It will call close()
if the package installer is popped-up to confirm the installation. Hence
we have to allow this use case without checking the caller.

Bug: 64467704
Test: gts-tradefed run singleCommand gts -m GtsPackageInstallSessionTestCases
Change-Id: I0bd0329c0485c50afa459d90c3372d7bf7408287
parent 3306c0d7
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -831,7 +831,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {

            // Commit was keeping session marked as active until now; release
            // that extra refcount so session appears idle.
            close();
            closeInternal(false);
            return;
        }

@@ -1388,9 +1388,16 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {

    @Override
    public void close() {
        closeInternal(true);
    }

    private void closeInternal(boolean checkCaller) {
        int activeCount;
        synchronized (mLock) {
            if (checkCaller) {
                assertCallerIsOwnerOrRootLocked();
            }

            activeCount = mActiveCount.decrementAndGet();
        }