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

View File

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