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

Commit 47aa8421 authored by Lee Shombert's avatar Lee Shombert
Browse files

Guard mThread in ProcessRecord

ProcessRecord.mThread is guarded by mService but synchronize blocks
are missing in three instances.  This adds in the synchronization.

Only the access to mThread is guarded.  The call into the mThread is
outside the synchronization block, to avoid deadlock.

Flag: EXEMPT bug-fix
Bug: 399561948
Test: atest
 * FrameworksServicesTests:com.android.server.am
 * FrameworksMockingServicesTests:com.android.server.am
Change-Id: I4de1f60b54515434b6bb61011fa0924ccd427f5f
parent 85c5b7d8
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -1443,17 +1443,32 @@ class ProcessRecord implements WindowProcessListener {

    void onProcessFrozen() {
        mProfile.onProcessFrozen();
        if (mThread != null) mThread.onProcessPaused();
        final ApplicationThreadDeferred t;
        synchronized (mService) {
            t = mThread;
        }
        // Release the lock before calling the notifier, in case that calls back into AM.
        if (t != null) t.onProcessPaused();
    }

    void onProcessUnfrozen() {
        if (mThread != null) mThread.onProcessUnpaused();
        final ApplicationThreadDeferred t;
        synchronized (mService) {
            t = mThread;
        }
        // Release the lock before calling the notifier, in case that calls back into AM.
        if (t != null) t.onProcessUnpaused();
        mProfile.onProcessUnfrozen();
        mServices.onProcessUnfrozen();
    }

    void onProcessFrozenCancelled() {
        if (mThread != null) mThread.onProcessPausedCancelled();
        final ApplicationThreadDeferred t;
        synchronized (mService) {
            t = mThread;
        }
        // Release the lock before calling the notifier, in case that calls back into AM.
        if (t != null) t.onProcessPausedCancelled();
        mServices.onProcessFrozenCancelled();
    }