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

Commit 7f5121b3 authored by Taran Singh's avatar Taran Singh
Browse files

Don't attach IME to letterboxed app windows.

When app is running in letterbox mode, don't attach IME to app window.
Test: Manually using steps in bug
Fix: 157870379

Change-Id: I857b47764c0b924370f553f3a02a4839934a5ec5
parent 31f583ee
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3625,7 +3625,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
@@ -2103,7 +2103,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
@@ -538,6 +538,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++) {