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

Commit c0e419b3 authored by Taran Singh's avatar Taran Singh Committed by Android (Google) Code Review
Browse files

Merge "Don't attach IME to letterboxed app windows."

parents 26b65abe 7f5121b3
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3643,7 +3643,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                && mImeLayeringTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
                // An activity with override bounds should be letterboxed inside its parent bounds,
                // so it doesn't fill the screen.
                && mImeLayeringTarget.mActivityRecord.matchParentBounds();
                && mImeLayeringTarget.mActivityRecord.matchParentBounds()
                // IME is attached to non-Letterboxed app windows, other than windows with
                // LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER flag. (Refer to WS.isLetterboxedAppWindow())
                && mImeLayeringTarget.matchesRootDisplayAreaBounds();
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -2097,7 +2097,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return getDisplayContent().getBounds().equals(getBounds());
    }

    private boolean matchesRootDisplayAreaBounds() {
    boolean matchesRootDisplayAreaBounds() {
        RootDisplayArea root = getRootDisplayArea();
        if (root == null || root == getDisplayContent()) {
            return matchesDisplayBounds();
+19 −0
Original line number Diff line number Diff line
@@ -540,6 +540,25 @@ public class DisplayContentTests extends WindowTestsBase {
        assertFalse(secondaryDisplay.shouldWaitForSystemDecorWindowsOnBoot());
    }

    @Test
    public void testImeIsAttachedToDisplayForLetterboxedApp() {
        final DisplayContent dc = mDisplayContent;
        final WindowState ws = createWindow(null, TYPE_APPLICATION, dc, "app window");
        dc.setImeLayeringTarget(ws);

        // Adjust bounds so that matchesRootDisplayAreaBounds() returns false and
        // hence isLetterboxedAppWindow() returns true.
        ws.mActivityRecord.getConfiguration().windowConfiguration.setBounds(new Rect(1, 1, 1, 1));
        assertFalse("matchesRootDisplayAreaBounds() should return false",
                ws.matchesRootDisplayAreaBounds());
        assertTrue("isLetterboxedAppWindow() should return true", ws.isLetterboxedAppWindow());
        assertTrue("IME shouldn't be attached to app",
                dc.computeImeParent() != dc.getImeTarget(IME_TARGET_LAYERING).getWindow()
                        .mActivityRecord.getSurfaceControl());
        assertEquals("IME should be attached to display",
                dc.getImeContainer().getParent().getSurfaceControl(), dc.computeImeParent());
    }

    private WindowState[] createNotDrawnWindowsOn(DisplayContent displayContent, int... types) {
        final WindowState[] windows = new WindowState[types.length];
        for (int i = 0; i < types.length; i++) {