Provide IME insets to freeform windows in the same task as IME target
After the change [1], for freeform windows, IME insets are provided only
when the target window is equals to the IME target.
However, we'd like to provide the IME insets as long as the target is in
the same task as the ime target window. This helps, for example, a case
where non-input-focusable but ime-focusable dialog window monitors IME
insets.
[1] Id376f73b7c3b0315834e9be4eecc21a826db85fc
Bug: 440265933
Test: ImeInsetsVisibilityTest
Flag: EXEMPT bug fix
Change-Id: Ieb5d7b40e18453a54806bcc2239681c2ba69606c
diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java
index 21d43b2..0a92eea 100644
--- a/services/core/java/com/android/server/wm/InsetsPolicy.java
+++ b/services/core/java/com/android/server/wm/InsetsPolicy.java
@@ -443,11 +443,12 @@
|| (windowingMode == WINDOWING_MODE_MULTI_WINDOW && target.isAlwaysOnTop())) {
// Keep frames, caption, and IME.
int types = WindowInsets.Type.captionBar();
- if (windowingMode != WINDOWING_MODE_PINNED) {
- if ((mDisplayContent != null && target == mDisplayContent.getImeInputTarget()
- && (WindowInsets.Type.ime() & target.getRequestedVisibleTypes()) != 0)) {
- types |= WindowInsets.Type.ime();
- }
+ if (windowingMode != WINDOWING_MODE_PINNED
+ && mDisplayContent.getImeInputTarget() instanceof WindowState imeTarget
+ && (target == imeTarget
+ || (target.getTask() != null && target.getTask() == imeTarget.getTask()))
+ && imeTarget.isRequestedVisible(WindowInsets.Type.ime())) {
+ types |= WindowInsets.Type.ime();
}
final InsetsState newState = new InsetsState();
newState.set(state, types);