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

Commit 0dd0cf91 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix issue with letterboxing

- Only consider client state if new API is actually turned on.
- We only sent the state the client was actually controlling.
However, we then later check for visibility for state that may not
even exist. Thus, we keep the state but only update the sources
the client is actually controlling.
- Initialize source with default visibility. This prevents
issues where the source may not exist but we still check it.

This fixes issues where a letterbox was accidentally placed on
screen because WM was thinking client requested fullscreen flag
(hiding the status bar), and other places where we checked
requested visibility.

Also renamed client state to requested state.

Test: Open any app, open IME
Bug: 111084606
Change-Id: Ibead561fc5593d8944400320f5e31dbe262612fe
parent 4e15b28e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public class InsetsSource implements Parcelable {
    public InsetsSource(@InternalInsetsType int type) {
        mType = type;
        mFrame = new Rect();
        mVisible = InsetsState.getDefaultVisibility(type);
    }

    public InsetsSource(InsetsSource other) {
+4 −0
Original line number Diff line number Diff line
@@ -102,8 +102,12 @@ public class InsetsSourceConsumerTest {

    @Test
    public void testShow() {

        // Insets source starts out visible
        mConsumer.hide();
        mConsumer.show();
        assertTrue("Consumer should be visible", mConsumer.isVisible());
        verify(mSpyInsetsSource).setVisible(eq(false));
        verify(mSpyInsetsSource).setVisible(eq(true));
    }

+5 −2
Original line number Diff line number Diff line
@@ -2192,10 +2192,13 @@ public class DisplayPolicy {
        final boolean attachedInParent = attached != null && !layoutInScreen;
        final boolean requestedFullscreen = (fl & FLAG_FULLSCREEN) != 0
                || (requestedSysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0
                || !win.getClientInsetsState().getSource(ITYPE_STATUS_BAR).isVisible();
                || (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL
                        && !win.getRequestedInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
        final boolean requestedHideNavigation =
                (requestedSysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0
                        || !win.getClientInsetsState().getSource(ITYPE_NAVIGATION_BAR).isVisible();
                || (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL
                        && !win.getRequestedInsetsState().getSource(ITYPE_NAVIGATION_BAR)
                                .isVisible());

        // TYPE_BASE_APPLICATION windows are never considered floating here because they don't get
        // cropped / shifted to the displayFrame in WindowState.
+3 −2
Original line number Diff line number Diff line
@@ -66,10 +66,11 @@ class InsetsPolicy {
        }
        mStatusBar.setVisible(focusedWin == null
                || focusedWin != getStatusControlTarget(focusedWin)
                || focusedWin.getClientInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
                || focusedWin.getRequestedInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
        mNavBar.setVisible(focusedWin == null
                || focusedWin != getNavControlTarget(focusedWin)
                || focusedWin.getClientInsetsState().getSource(ITYPE_NAVIGATION_BAR).isVisible());
                || focusedWin.getRequestedInsetsState().getSource(ITYPE_NAVIGATION_BAR)
                        .isVisible());
    }

    boolean isHidden(@InternalInsetsType int type) {
+1 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
            final WindowState windowState = mService.windowForClientLocked(this, window,
                    false /* throwOnError */);
            if (windowState != null) {
                windowState.setClientInsetsState(state);
                windowState.updateRequestedInsetsState(state);
                windowState.getDisplayContent().getInsetsPolicy().onInsetsModified(
                        windowState, state);
            }
Loading