From 2a1ef7a72fa99133e9d61bfda7294edbfbab8836 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Sun, 27 Mar 2022 15:12:42 -0700 Subject: [PATCH] DisplayContent: Don't force-update parent if layering didn't change A recent change to provide IME support for SurfaceControlViewHost modified logic for setImeLayeringTargetInner. setImeLayeringTarget inner also updates the control target, which may depend on the input target. In the case of SurfaceControlViewHost the input target can change with the layering target not changing, and so we need to update the control target, which was done by extending the conditions on the return at the beginning of setImeLayeringTargetInner to also include the check for mLastImeInputTarget == mImeInputTarget. However in standard app cases, this can produce a scenario where we consider the IME parent as changed, even when it wasn't (when neither the layering or the control target update). This CL partially restores the previous logic by not forcing the IME parent update when the layering target didn't really change. Bug: 226338567 Test: Existing tests pass Change-Id: I8ec9583feca8a0be9c90b0a4a2a382bf915ae4be --- services/core/java/com/android/server/wm/DisplayContent.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 8eb0046ff9237..6c1b5bcdccfd6 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -3979,6 +3979,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } ProtoLog.i(WM_DEBUG_IME, "setInputMethodTarget %s", target); + final boolean layeringTargetChanged = target != mImeLayeringTarget; mImeLayeringTarget = target; // 1. Reparent the IME container window to the target root DA to get the correct bounds and @@ -4006,7 +4007,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // 4. Update the IME control target to apply any inset change and animation. // 5. Reparent the IME container surface to either the input target app, or the IME window // parent. - updateImeControlTarget(true /* forceUpdateImeParent */); + updateImeControlTarget(layeringTargetChanged); } @VisibleForTesting