From f9705dd8b1cd051132a0175941405cd5a9ae94ae Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Fri, 1 Jul 2022 19:41:24 +0800 Subject: [PATCH] Refine excludeInvisibleImeFrames When adding a window to WMS, its z-order may be higher than IME initially. And then, WMS will move IME to the top of the new window. Although IME is invisible during launching an app, that causes a change in WindowState#mAboveInsetsState. And it would trigger a redundant onApplyWindowInsets at the client side. This CL treats null IME source as invisible IME source in InsetsState#equals when excludeInvisibleImeFrames is true. Bug: 237749017 Test: Add logs in dispatchApplyWindowInsets, and see if it gets printed twice while launching an app. Change-Id: I5eba7732619f7ceebe3152e81037a43e9ab3d91f --- core/java/android/view/InsetsState.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java index 11e02e03c4e46..6a0ec3368f19c 100644 --- a/core/java/android/view/InsetsState.java +++ b/core/java/android/view/InsetsState.java @@ -909,6 +909,11 @@ public class InsetsState implements Parcelable { if (source == null && otherSource == null) { continue; } + if (excludeInvisibleImeFrames && i == ITYPE_IME + && ((source == null && !otherSource.isVisible()) + || (otherSource == null && !source.isVisible()))) { + continue; + } if (source == null || otherSource == null) { return false; }