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

Commit 6f61204b authored by Craig Mautner's avatar Craig Mautner
Browse files

Lock down window manager while changing opacity

Surfaces were being modified after destroy(). The check for mSurface
being null was not done while holding window the window manager lock.
This change adds locking to the surface modification methods.

Fixes bug 17383628.

Change-Id: I12ebbddc0f2cd7b43659370fac2c4fb053999bb5
parent 68c936f7
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -4303,20 +4303,28 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    public void setAppFullscreen(IBinder token, boolean toOpaque) {
        synchronized (mWindowMap) {
            AppWindowToken atoken = findAppWindowToken(token);
            if (atoken != null) {
                atoken.appFullscreen = toOpaque;
            setWindowOpaque(token, toOpaque);
            requestTraversal();
                setWindowOpaqueLocked(token, toOpaque);
                requestTraversalLocked();
            }
        }
    }

    public void setWindowOpaque(IBinder token, boolean isOpaque) {
        synchronized (mWindowMap) {
            setWindowOpaqueLocked(token, isOpaque);
        }
    }

    public void setWindowOpaqueLocked(IBinder token, boolean isOpaque) {
        AppWindowToken wtoken = findAppWindowToken(token);
        if (wtoken != null) {
            WindowState win = wtoken.findMainWindow();
            if (win != null) {
                win.mWinAnimator.setOpaque(isOpaque);
                win.mWinAnimator.setOpaqueLocked(isOpaque);
            }
        }
    }
+3 −3
Original line number Diff line number Diff line
@@ -1556,11 +1556,11 @@ class WindowStateAnimator {
        }
    }

    void setOpaque(boolean isOpaque) {
    void setOpaqueLocked(boolean isOpaque) {
        if (mSurfaceControl == null) {
            return;
        }
        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setOpaque");
        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setOpaqueLocked");
        SurfaceControl.openTransaction();
        try {
            if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, "isOpaque=" + isOpaque,
@@ -1568,7 +1568,7 @@ class WindowStateAnimator {
            mSurfaceControl.setOpaque(isOpaque);
        } finally {
            SurfaceControl.closeTransaction();
            if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION setOpaque");
            if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION setOpaqueLocked");
        }
    }