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

Commit 6e11e049 authored by jorgegil@google.com's avatar jorgegil@google.com
Browse files

Dump DisplayModeDirector state without locking mSyncRoot

The current locking order of DisplayManagerGlobal.mLock,
DisplayManagerService.mSyncRoot and SensorObserver.mSensorObserverLock
may cause a deadlock when an EVENT_DISPLAY_CHANGED event is handled
by MediaRouter.Static and DMD.SensorObserver at the same time as
a DisplayManagerService dump is in progress.

The locking order of onDisplayChanged is:
   - mSensorObserverLock -> DMG.mLock -> DMS.mSyncRoot
The locking order of DMS.dumpInternal is:
   - DMS.mSyncRoot -> mSensorOberverLock

This change removes the mSyncRoot locking during the DMD dump to keep
the lock ordering from going in a cycle. DMD already guards its state
during a dump with its own class lock, so holding mSyncRoot is not
really necessary.

Bug: 202515175
Test: builds
Change-Id: I464e570e7107b49633e599b25ef1d208c9fc76aa
parent f23eb51d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2062,9 +2062,6 @@ public final class DisplayManagerService extends SystemService {
            pw.println();
            mLogicalDisplayMapper.dumpLocked(pw);

            pw.println();
            mDisplayModeDirector.dump(pw);

            final int callbackCount = mCallbacks.size();
            pw.println();
            pw.println("Callbacks: size=" + callbackCount);
@@ -2087,6 +2084,8 @@ public final class DisplayManagerService extends SystemService {
            pw.println();
            mPersistentDataStore.dump(pw);
        }
        pw.println();
        mDisplayModeDirector.dump(pw);
    }

    private static float[] getFloatArray(TypedArray array) {