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

Commit a4c0fc9a authored by Charles Chen's avatar Charles Chen
Browse files

Cache OverContext to prevent deadlock

There may be a deadlock if WMS is obtaining DisplayInfo during
creating SystemUiContext on seconday display
while PMS is querying current power state from DMS.
This CL caches the OverlayContext used in LocalDisplayAdapter
to prevent DMS from holding ActivityThread lock.

fixes: 227308239
Test: atest LocalDisplayAdapterTest
Change-Id: I41c44ea070673f048b49d108e029ae90d96645ad
parent 18f93518
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ final class LocalDisplayAdapter extends DisplayAdapter {

    private final boolean mIsBootDisplayModeSupported;

    private Context mOverlayContext;

    // Called with SyncRoot lock held.
    public LocalDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
            Context context, Handler handler, Listener listener) {
@@ -1222,7 +1224,10 @@ final class LocalDisplayAdapter extends DisplayAdapter {

    /** Supplies a context whose Resources apply runtime-overlays */
    Context getOverlayContext() {
        return ActivityThread.currentActivityThread().getSystemUiContext();
        if (mOverlayContext == null) {
            mOverlayContext = ActivityThread.currentActivityThread().getSystemUiContext();
        }
        return mOverlayContext;
    }

    /**