Skip to content
Commit 1ef07dff authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

Fix showing keyboard without editor focused in some cases (1/2)

Starts from CL[1] that reporting focus change is now driven by
input instead window manager, so the window focus sequence for the
activity with EditTextPreference dialog after device unlock
in between android Q and android R will be:

[Android Q]:
activity main window (with softInputMode STATE_UNSPECIFIED)
    -> EditTextPreference (with softInputMode STATE_ALWAYS_VISIBLE)

[Android R]:
Only EditTextPreference focused after device unlocked since the window
is the last touched window.

Since in Q, the softInputMode of activity main window is STATE_UNSPECIFIED
, so by default InputMethodManagerService will hide soft-keyboard if there
is no editor focused according this softInputMode flag.

However, in R, because no main window focused, so after EditTextPerference
focused and started the input connection, this will hit a logic to show
soft-keyboard, if mShowRequested is true after the input session created.

Since IMMS#mShowRequested originally is used to show soft-input while
showSoftInput is called but IME service has been unbounded (e.g. switch IME
or IME service killed), so use this flag can show soft-input aftter
service re-connected.  For the issue case, we should ignore
STATE_ALWAYS_VISIBLE since the app's targetSdkVersion is P+ and no
editor focus as CL[2] expectation.

To fix that, first in IMMS side, we need to make sure to check
startInputFlag and showSoftInputFlag again, even the focused window of
the next start input is same, we still need to check its flag to show
/ hide keyboard, once the flags changed or the view focus cleared.

[1]: Iff0b88a05441b29834741aa3dfae31d55871ddd6
[2]: I56682c7dee71d461687b9e80ab746d382fd55e0c

Bug: 161506356
Fix: 162444230
Test: atest CtsInputMethodTestCases
Change-Id: I37ae6e30d1de581ba15131c2a90396b3a522a4d6
parent a806511d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment