From 6ba743217341be74df5c3b09a8f3e6088445fd14 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Mon, 8 Nov 2021 02:13:07 +0800 Subject: [PATCH] Revert hide logic in ImeInsetsSourceConsumer#setControl CL[1] using isRequestedVisibleAwaitingControl() in ImeInsetsSourceconsumer#setControl to hide IME surface when it returned false without waiting control or requesting visible to deal with the unexpecting hide IME cases during the testing. However, when calling IMM#toggleSoftInput to reqest showing keyboard on the dialog implicitly that will set requrested visible on both the caller window and the dialog window, since toggleSoftInput didn't explicit set the target window but just using the caller window as requester implicitly. It causes a regression that can't hide the IME surface when dismissing the dialog to back to the caller window that the IME insets source control is null but isRequestedVisibleAwaitingControl still returned true because isRequestedVisible has been set true for the toggerSoftInput caller window. Revert logic in setControl to use mIsRequestedVisibleAwaitingControl in case the IME surface won't be removed when backing to the implicit caller window of toggleSoftInput. [1]: I3071af14bf78e23f9526d6a9c138ab6ae2e0e339 Bug: 207092186 Bug: 204524304 Test: manual Test: atest CtsInputMethodTestCases Test: atest WindowInsetsAnimationControllerTests Change-Id: Ic5265a6c3f2eba77d43832d23309998bf3cb1671 --- core/java/android/view/ImeInsetsSourceConsumer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/ImeInsetsSourceConsumer.java b/core/java/android/view/ImeInsetsSourceConsumer.java index 02b2c5d5db84c..d609fb8eb2342 100644 --- a/core/java/android/view/ImeInsetsSourceConsumer.java +++ b/core/java/android/view/ImeInsetsSourceConsumer.java @@ -124,7 +124,12 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { public void setControl(@Nullable InsetsSourceControl control, int[] showTypes, int[] hideTypes) { super.setControl(control, showTypes, hideTypes); - if (control == null && !isRequestedVisibleAwaitingControl()) { + // TODO(b/204524304): clean-up how to deal with the timing issues of hiding IME: + // 1) Already requested show IME, in the meantime of WM callback the control but got null + // control when relayout comes first + // 2) Make sure no regression on some implicit request IME visibility calls (e.g. + // toggleSoftInput) + if (control == null && !mIsRequestedVisibleAwaitingControl) { hide(); removeSurface(); }