From 60089b284beec09e3faa4497ffb31ab84cf993ff Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 13 Jul 2021 22:30:45 -0700 Subject: [PATCH] Avoid redundant InputConnection#reportFullscreenMode() callback This is a follow up CL to our previous attempts [1][2] to make InputMethodManager#isFullscreenMode() be reliable and predictable. What we haven't changed in our previous efforts is an edge case where newly created InputMethodService always triggers InputConnection#reportFullscreenMode() even when the same value is already returned from InputMethodManager#isFullscreenMode(). Note that this is one-shot anomaly and would not repeat once InputMethodService creates its window once. Although most of app developers would not be having troubles, not having such a special behavior is in general preferable. Not having a special behavior only after creating an IME is also important for our CTS, where we always recreate MockIme to verify the system behavior from a known state. As whether an IME is newly instantiated or not is not something apps can easily rely on, changing this long-standing behavior is supposed to be safe. [1]: Iba184245a01a3b340f006bc4e415d304de3c2696 1544def0facda69c210b0ae64b17394ea2860d39 [2]: If23e7c7c265ab3dfb48c2fb6fdb361b17d22c594 2bc66171cce4d5ae7bee2c3920e82e45a9d245af Bug: 129012881 Fix: 193589328 Test: atest CtsInputMethodTestCases:InputConnectionEndToEndTest Change-Id: I7f600d9eefe200b99508e590ad8c2681643248a0 --- core/java/android/view/inputmethod/InputMethodManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 110bd33ffeef3..80a6c02f6389d 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -957,9 +957,10 @@ public final class InputMethodManager { final boolean fullscreen = msg.arg1 != 0; InputConnection ic = null; synchronized (mH) { - mFullscreenMode = fullscreen; - if (mServedInputConnectionWrapper != null) { + if (mFullscreenMode != fullscreen + && mServedInputConnectionWrapper != null) { ic = mServedInputConnectionWrapper.getInputConnection(); + mFullscreenMode = fullscreen; } } if (ic != null) {