From a2e6a9d6d3a5939e2da4889fb418fcd29d13a381 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Wed, 6 Oct 2021 17:00:19 +0800 Subject: [PATCH] Fix wrong check in DC#needsRelativeLayeringToIme Previous CL[1] uses isImeAttachedToApp to check if the IME should set relative layer with the app window, but it's wrong because the method also check if the IME parent has reparented to the app. (This brakes RoleManagerTest failure as Bug 202246318, since the test activity has created a child window but we accidentally set the wrong relative layer of IME even the activity didn't request showing IME, so the child window will end up not be on the top of screen) As originally CL[1] is only need to check if the window is eligible to attach IME then we don't need to set relative layer for IME, use shouldImeAttachedToApp to fix the original issue and unblock RoleManagerTest failure. Also move allowAttachToApp related with magnicationSpec check from computeImeParent into shouldImeAttachedToApp to make the attach logic more consistent. [1]: I2f466a2305e56e4fd2a0c509d7c8027104cb51b6 Fix: 202227155 Fix: 202246318 Bug: 201504527 Test: atest RoleManagerTest ZOrderingTests Change-Id: Ib6233b8f9270829a7d7c6fbb3bd98fdefaf4c206 --- .../java/com/android/server/wm/DisplayContent.java | 12 ++++++------ .../core/java/com/android/server/wm/WindowState.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 5f03f89624876..46a4f8a266731 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -3804,7 +3804,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } boolean shouldImeAttachedToApp() { - return isImeControlledByApp() + // Force attaching IME to the display when magnifying, or it would be magnified with + // target app together. + final boolean allowAttachToApp = (mMagnificationSpec == null); + + return allowAttachToApp && isImeControlledByApp() && mImeLayeringTarget != null && mImeLayeringTarget.mActivityRecord != null && mImeLayeringTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN @@ -4143,14 +4147,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp */ @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 (allowAttachToApp && shouldImeAttachedToApp()) { + if (shouldImeAttachedToApp()) { if (mImeLayeringTarget.mActivityRecord != mImeInputTarget.mActivityRecord) { // Do not change parent if the window hasn't requested IME. return null; diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 6afa2e0f690dd..ad4734f0526c1 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -5681,7 +5681,7 @@ class WindowState extends WindowContainer implements WindowManagerP // elevating the IME and windows above it's target above the docked divider in // split-screen, or make the popupMenu to be above the IME when the parent window is the // IME layering target in bubble/freeform mode. - if (mDisplayContent.isImeAttachedToApp()) { + if (mDisplayContent.shouldImeAttachedToApp()) { return false; }