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
      1544def0fa
 [2]: If23e7c7c265ab3dfb48c2fb6fdb361b17d22c594
      2bc66171cc

Bug: 129012881
Fix: 193589328
Test: atest CtsInputMethodTestCases:InputConnectionEndToEndTest
Change-Id: I7f600d9eefe200b99508e590ad8c2681643248a0
This commit is contained in:
Yohei Yukawa
2021-07-13 22:30:45 -07:00
parent 451e93eacb
commit 60089b284b

View File

@@ -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) {