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

Commit 6d6f67cd authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix IME is beyond the screen if the app doesn't fill its parent bounds

An activity with fixed aspect ratio may not cover the entire screen.
Once the left of the app surface is not the same as the left display
dock frame, the IME will be beyond the screen.

Bug: 128581369
Test: atest DisplayContentTests#testComputeImeParent_app_notMatchParentBounds
Test: manual - Launch a landscape activity with fixed aspect ratio 1.2.
      Click the input field in the activity and check the IME position.

Change-Id: If4125a18042e45efae1f8115008b0374b2669084
parent bbe19695
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -3271,8 +3271,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        // Attach it to app if the target is part of an app and such app is covering the entire
        // screen. If it's not covering the entire screen the IME might extend beyond the apps
        // bounds.
        if (mInputMethodTarget != null && mInputMethodTarget.mAppToken != null &&
                mInputMethodTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
        if (mInputMethodTarget != null && mInputMethodTarget.mAppToken != null
                && mInputMethodTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
                // An activity with override bounds should be letterboxed inside its parent bounds,
                // so it doesn't fill the screen.
                && mInputMethodTarget.mAppToken.matchParentBounds()) {
            return mInputMethodTarget.mAppToken.getSurfaceControl();
        }

+11 −1
Original line number Diff line number Diff line
@@ -34,11 +34,12 @@ import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.eq;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.same;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.times;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
@@ -662,6 +663,15 @@ public class DisplayContentTests extends WindowTestsBase {
        }
    }

    @Test
    public void testComputeImeParent_app_notMatchParentBounds() {
        spyOn(mAppWindow.mAppToken);
        doReturn(false).when(mAppWindow.mAppToken).matchParentBounds();
        mDisplayContent.mInputMethodTarget = mAppWindow;
        // The surface parent of IME should be the display instead of app window.
        assertEquals(mDisplayContent.getWindowingLayer(), mDisplayContent.computeImeParent());
    }

    @Test
    public void testComputeImeParent_noApp() throws Exception {
        try (final InsetsModeSession session =