From f03366ee1641c792c131987b29aef5d3594ee454 Mon Sep 17 00:00:00 2001 From: Wilson Wu Date: Thu, 17 Dec 2020 21:13:31 +0800 Subject: [PATCH] [DO NOT MERGE] DisplayImeController: fix out-of-sync IME visibility This change is based on CL[1] in rvc-qpr-dev code base. Note: This cherry-picked change isn't completely same as master one, it add a method "getImeRequestedVisibility" in InsetsControlTarget since "getRequestedVisibility" didn't exist in rvc-qpr currently. Fixes an issue where the DisplayImeController would disagree with the InputMethodManagerService about the visibility of the IME. Currently, the Insets component is supposed to execute the visibility as dictated by IMMS; however, when the DisplayImeController became the control target, previously it would just apply the IME visibility that was last requested of it - regardless of the changes to it that may have happened while it was not the control target. Eventually, IME visibility should be driven by the requested IME inset visibility of the focused window, instead of the separate dispatch we have now from IMMS. [1]:I1f140af6bcccbcbe6efb2fde9a789ac4c7bd127f Bug: 167780081 Test: atest ImeInsetsSourceProviderTest Change-Id: I3962f3aa26d9325d7d8a4611f13a637d46337fef --- .../systemui/wm/DisplayImeController.java | 2 ++ .../com/android/server/wm/DisplayContent.java | 5 ++++ .../server/wm/ImeInsetsSourceProvider.java | 26 ++++++++++++++++--- .../server/wm/InsetsControlTarget.java | 7 +++++ .../server/wm/InsetsSourceProvider.java | 2 +- .../server/wm/WindowManagerService.java | 3 +++ .../wm/ImeInsetsSourceProviderTest.java | 20 ++++++++++++++ .../android/server/wm/WindowTestsBase.java | 9 +++++++ 8 files changed, 70 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java b/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java index dd4ea578dafef..ab4da83518e40 100644 --- a/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java +++ b/packages/SystemUI/src/com/android/systemui/wm/DisplayImeController.java @@ -203,6 +203,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged return; } + mImeShowing = insetsState.getSourceOrDefaultVisibility(InsetsState.ITYPE_IME); + final InsetsSource newSource = insetsState.getSource(InsetsState.ITYPE_IME); final Rect newFrame = newSource.getFrame(); final Rect oldFrame = mInsetsState.getSource(InsetsState.ITYPE_IME).getFrame(); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index adf0b44040d9d..2ef98b59768f5 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -5877,6 +5877,11 @@ class DisplayContent extends WindowContainer