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, we introduced new SoftInputShowHideReason to hide soft-input when the same window focused without valid editor focus after screen unlock, in order to align with the behavior prior to R. [1]: Iff0b88a05441b29834741aa3dfae31d55871ddd6 [2]: I56682c7dee71d461687b9e80ab746d382fd55e0c Bug: 161506356 Fix: 162444230 Test: atest CtsInputMethodTestCases Merged-In: I37ae6e30d1de581ba15131c2a90396b3a522a4d6 Change-Id: I37ae6e30d1de581ba15131c2a90396b3a522a4d6 (cherry picked from commit 1ef07dff)
Loading
Please register or sign in to comment