Unbind current IME immediately after switching
Currently when we switch to a different IME we only unbind the current
client, which calls InputMethodManager#setActive(false). Here, we try to
call startInput, which ends up unbinding the current IME and binding the
new one. However, if the current client does not have input focus
anymore, we early exit before calling startInput, leaving the previous
IME bound. The next time we startInput by either this client or another
getting input focus, we switch the bound IME successfully.
This can happen if some dialog gets input focus (e.g. a dialog from
inside the IME itself, or the IME Switcher menu dialog) and the user
switches to a different IME in this state.
This adds a call to directly unbind the current IME whenever we
successfully switch to a different one, with the binding of the new IME
happening in the next successful startInput call.
With this change we could enter a case where some dialog (other than one
inside the IME or the IME switcher menu dialog) gets input focus and the
user switches to a different IME, which will directly close the current
one, without closing the dialog itself, however that should lead to an
overall better experience (as switching IMEs should at the very least
stop the current one).
Flag: EXEMPT bugfix
Test: atest ImeSwitchingTest#testImeUnboundAfterSwitchingWithoutInputFocus
Bug: 359382114
Change-Id: If2f858c936ac2a30346233afc477f091b85263c9
1 file changed