From 48441703770de186ae9e81aadd6be38233812a4d Mon Sep 17 00:00:00 2001 From: Kohsuke Yatoh Date: Tue, 12 Apr 2022 15:14:53 -0700 Subject: Notify IMMS synchronously on IME insets hidden. Currently, IMMS will be notified asynchronously when an IME hide animation finishes, via message dispatching through IMS (IMM#notifyImeHidden -> IMS#notifyImeHidden -> IMMS#hideMySoftInput). This creates a race condition when IMM#showSoftInput or WIC#show is called around the end of hide animation. This CL fixes the race condition by synchronously and directly calling IMMS#hideSoftInput from IMM#notifyImeHidden. Note that there is still another race condition for IMM#showSoftInput (not WIC#show) if it's called during an IME hide animation; IMM#showSoftInput ended up calling WIC#show asynchronously, but at that time the running IME hide animation may have already been finished successfully and WIC#show may fail to cancel the hide animation (then the cleanup IMM#notifyImeHidden hides the IME again disruptively). I will fix the latter issue in a separate CL. Bug: 221483132 Bug: 225674038 Test: atest InputMethodStressTest Test: atest CtsInputMethodTestCases Test: atest WindowInsetsAnimationControllerTests Change-Id: I7c71dc5a1d6b61aa79d1666f0e257e6401e4adb2 (cherry picked from commit 9065310f814d38c5d8dea5f01655b30e4996fef4) Merged-In: I7c71dc5a1d6b61aa79d1666f0e257e6401e4adb2 --- core/java/android/inputmethodservice/InputMethodService.java | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 4fdd53425328..a6ed42348af6 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -1058,10 +1058,6 @@ public class InputMethodService extends AbstractInputMethodService { return viewRoot == null ? null : viewRoot.getInputToken(); } - private void notifyImeHidden() { - requestHideSelf(0); - } - private void scheduleImeSurfaceRemoval() { if (mShowInputRequested || mWindowVisible || mWindow == null || mImeSurfaceScheduledForRemoval) { @@ -1224,14 +1220,6 @@ public class InputMethodService extends AbstractInputMethodService { InputMethodService.this.onUpdateCursorAnchorInfo(info); } - /** - * Notify IME that window is hidden. - * @hide - */ - public final void notifyImeHidden() { - InputMethodService.this.notifyImeHidden(); - } - /** * Notify IME that surface can be now removed. * @hide -- cgit v1.2.3