Merge "DisplayArea: Fix computation of ImeContainers parent surface" into rvc-dev

This commit is contained in:
Adrian Roos
2020-04-14 18:58:58 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 11 deletions

View File

@@ -3457,11 +3457,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();
@@ -3473,16 +3469,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() {
@@ -4727,6 +4726,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());
}
}