Make IMM more robust for window focus stealing
This CL is a generalized version of my previous CL [1], which addresed
Bug
31056744 where InputMethodManager (IMM) fails to recover from
failure mode when IMMS#startInputOrWindowGainedFocus() failes because
the app's window is no longer eligible to be the IME target.
This CL finally addressed one TODO in that CL. InputBindResult now has
the error code, which allows us to force restart input upon the next
window-focus-in event. This should make IMM much more robust for
that kind of failure modes. For instance, Bug
70629102 is fixed as
demonstrated in a newly added CTS test case [2]. Hopefully this may
also fix Bug
31056744, which we still do not know how to reproduce.
[1]: I60adb38013b063918b074c7b947649eada77b2c8
8e9214b4bd7e6a9d944ad1527199226e575a7530
[2]: I4ea24c87cbbd05e4e68ad7dfafb774c8520188e2
Bug:
31056744
Fixes:
70629102
Test: Added a test case for Bug
70629102
atest CtsInputMethodTestCases
Test: Manually made sure that Bug
28281870 is still fixed:
1. Open app that has EditText.
2. Start Input.
3. Long press the task switch button to start multi-window mode.
4. Tap the EditText that is used in step 2.
5. Make sure that the IME still works as expected
Test: atest CtsViewTestCates
Change-Id: I7572d4b9d678f3669ca54d55718877b145015777