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

Commit 7737398f authored by Adrian Roos's avatar Adrian Roos
Browse files

WM: Stop tampering with sysuiVisibility for layout

Instead of changing the sysuiVisibility to get the desired layout behavior
calculate the implied sysuiVisibility flags at layout time. This allows us
to check what the window originally requested, which will be needed later
for cutout-aware layout.

Bug: 65689439
Test: runtest -x services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerLayoutTest.java
Change-Id: I195f7b8ad535731614ea8f5fb2af2f001fd13036
parent e1856fe7
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -2666,17 +2666,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // The status bar is the only window allowed to exhibit keyguard behavior.
            attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
        }
    }

    private int getImpliedSysUiFlagsForLayout(LayoutParams attrs) {
        int impliedFlags = 0;
        if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) {
            attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
            impliedFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        }
        final boolean forceWindowDrawsStatusBarBackground =
                (attrs.privateFlags & PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND) != 0;
        if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
                || forceWindowDrawsStatusBarBackground
                        && attrs.height == MATCH_PARENT && attrs.width == MATCH_PARENT) {
            attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
            impliedFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        }
        return impliedFlags;
    }

    void readLidState() {
@@ -4832,7 +4836,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final int fl = PolicyControl.getWindowFlags(win, attrs);
        final int pfl = attrs.privateFlags;
        final int sim = attrs.softInputMode;
        final int sysUiFl = PolicyControl.getSystemUiVisibility(win, null);
        final int requestedSysUiFl = PolicyControl.getSystemUiVisibility(win, null);
        final int sysUiFl = requestedSysUiFl | getImpliedSysUiFlagsForLayout(attrs);

        final Rect pf = mTmpParentFrame;
        final Rect df = mTmpDisplayFrame;
+11 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;

import static org.junit.Assert.assertEquals;

import android.graphics.PixelFormat;
import android.platform.test.annotations.Presubmit;
import android.support.test.filters.SmallTest;
@@ -94,4 +96,13 @@ public class PhoneWindowManagerLayoutTest extends PhoneWindowManagerTestBase {
        assertInsetByTopBottom(mAppWindow.contentFrame, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
        assertInsetByTopBottom(mAppWindow.decorFrame, 0, NAV_BAR_HEIGHT);
    }

    @Test
    public void addingWindow_doesNotTamperWithSysuiFlags() {
        mAppWindow.attrs.flags |= FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
        mPolicy.addWindow(mAppWindow);

        assertEquals(0, mAppWindow.attrs.systemUiVisibility);
        assertEquals(0, mAppWindow.attrs.subtreeSystemUiVisibility);
    }
}
 No newline at end of file