DisplayArea: Fix computation of ImeContainers parent surface

When not attached to an activity, the IME container must be attached
where the DisplayAreaPolicy placed it, not in WindowContainers.

Fixes: 150943539
Test: atest DisplayContentTests
Change-Id: Ia205f4ce53cfa063651a0010258f14fc1a22f5ef
This commit is contained in:
Adrian Roos
2020-04-14 15:42:41 +02:00
parent 1a75b43563
commit 329cbd0e8d
2 changed files with 16 additions and 11 deletions

View File

@@ -3472,11 +3472,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
}
private void updateImeParent() {
// Force attaching IME to the display when magnifying, or it would be magnified with
// target app together.
final boolean shouldAttachToDisplay = (mMagnificationSpec != null);
final SurfaceControl newParent =
shouldAttachToDisplay ? mWindowContainers.getSurfaceControl() : computeImeParent();
final SurfaceControl newParent = computeImeParent();
if (newParent != null) {
getPendingTransaction().reparent(mImeWindowsContainers.mSurfaceControl, newParent);
scheduleAnimation();
@@ -3488,16 +3484,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
*/
@VisibleForTesting
SurfaceControl computeImeParent() {
// Force attaching IME to the display when magnifying, or it would be magnified with
// target app together.
final boolean allowAttachToApp = (mMagnificationSpec == null);
// 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 (isImeAttachedToApp()) {
if (allowAttachToApp && isImeAttachedToApp()) {
return mInputMethodTarget.mActivityRecord.getSurfaceControl();
}
// Otherwise, we just attach it to the display.
return mWindowContainers.getSurfaceControl();
// Otherwise, we just attach it to where the display area policy put it.
return mImeWindowsContainers.getParent().getSurfaceControl();
}
void setLayoutNeeded() {
@@ -4732,6 +4731,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
return mWindowContainers.getSurfaceControl();
}
@VisibleForTesting
WindowContainer<?> getImeContainer() {
return mImeWindowsContainers;
}
SurfaceControl getOverlayLayer() {
return mOverlayContainers.getSurfaceControl();
}

View File

@@ -826,7 +826,7 @@ public class DisplayContentTests extends WindowTestsBase {
dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "app");
dc.mInputMethodTarget.setWindowingMode(
WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
assertEquals(dc.getWindowingLayer(), dc.computeImeParent());
assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
}
}
@@ -836,7 +836,8 @@ public class DisplayContentTests extends WindowTestsBase {
doReturn(false).when(mAppWindow.mActivityRecord).matchParentBounds();
mDisplayContent.mInputMethodTarget = mAppWindow;
// The surface parent of IME should be the display instead of app window.
assertEquals(mDisplayContent.getWindowingLayer(), mDisplayContent.computeImeParent());
assertEquals(mDisplayContent.getImeContainer().getParentSurfaceControl(),
mDisplayContent.computeImeParent());
}
@Test
@@ -845,7 +846,7 @@ public class DisplayContentTests extends WindowTestsBase {
new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {
final DisplayContent dc = createNewDisplay();
dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "statusBar");
assertEquals(dc.getWindowingLayer(), dc.computeImeParent());
assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
}
}