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
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index b26aa05..98333b2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -34,11 +34,12 @@
 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;
@@ -663,6 +664,15 @@
     }
 
     @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 =
                      new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {