From 5fcf28e8bd5df056c12d1bc151d275ac398e07d2 Mon Sep 17 00:00:00 2001 From: Taran Singh Date: Mon, 26 Apr 2021 19:17:29 +0000 Subject: [PATCH] Update IME parent onConfigurationChanged When an app is moving between fold and unfold state, screenWidth will change in DisplayContent#onConfigurationChanged() and depending on if InputTarget is not-resizeable window, IME should no longer be attached to the app to use full width. We should update IME parent by calling updateImeParent() and it shall take care of handling all such cases. Fix: 183484673 Test: atest DisplayContentTests Change-Id: I9e892c4c320c61d4a9ceefaf309e76b816c73388 --- services/core/java/com/android/server/wm/DisplayContent.java | 5 ++++- .../src/com/android/server/wm/DisplayContentTests.java | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 91f75e57c092f..1a6743851f408 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -2409,6 +2409,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mDisplayPolicy.onConfigurationChanged(); mPinnedTaskController.onPostDisplayConfigurationChanged(); } + // Update IME parent if needed. + updateImeParent(); if (lastOrientation != getConfiguration().orientation) { getMetricsLogger().write( @@ -3947,7 +3949,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } // Otherwise, we just attach it to where the display area policy put it. - return mImeWindowsContainer.getParent().getSurfaceControl(); + return mImeWindowsContainer.getParent() != null + ? mImeWindowsContainer.getParent().getSurfaceControl() : null; } void setLayoutNeeded() { 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 e09606e3389f2..4afad30b34fc0 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -349,7 +349,9 @@ public class DisplayContentTests extends WindowTestsBase { doReturn(imeSurfaceParent).when(mDisplayContent).computeImeParent(); spyOn(imeContainer); - mDisplayContent.updateImeParent(); + mDisplayContent.setImeInputTarget(startingWin); + mDisplayContent.onConfigurationChanged(new Configuration()); + verify(mDisplayContent).updateImeParent(); // Force reassign the relative layer when the IME surface parent is changed. verify(imeContainer).assignRelativeLayer(any(), eq(imeSurfaceParent), anyInt(), eq(true));