Update IME focus when the active view is losing the focus.
Despite the fact that IMM#focusOut() are called from many focus
mangement logics, the reality is that IMM#focusOut() has done
nothing more than 6 years. This would not a big problem as long
as IMM#focusIn() is called immediately after IMM#focusOut().
However, situations where only IMM#focusOut() is called,
following fields continue keeping object references.
- IMM#mServedView
- IMM#mNextServedView
- IMM#mServedInputConnection
- IMM#mServedInputConnectionWrapper
Even worse, if the IME is showing software keyboard, it will not
be dismissed.
With this CL, IMM#focusOut() starts cleaning up the active IME
session when the associated view loses focus.
This CL also removes IMM#mCurRootView because it is indeed
necessary for above change. The problem when only introducing
above change can be understood as follows.
1. IMM#mCurRootView is correctly set from ViewRootImpl.
2. IMM#focusIn() is called. InputConnection is established.
3. IMM#focusOut() is called, which triggers
IMM#finishInputLocked() because of above change, which
internally clears IMM#mCurRootView.
4. IMM#focusIn() is called but IMM#mCurRootView is still null.
Because of this the focus-in event is ignored and the
software keyboard does not show up anymore.
In this CL, we simply check view.hasWindowFocus() instead.
As far as I've tested, this change looks to be working well.
Bug: 20820914
Change-Id: Ib4bd70ce0305a6bde6a929bcc6ad20a2b8402a97
3 files changed