Fix stuck IME when IME dialog is focused

Only the currently focused window will invoke startInput, and thus control the IME.

However, if the IME puts up a focusable dialog, and the requesting activity restarts,
its new window won't regain focus - because the IME dialog still has it. Thus, IMMS
never receives a startInput, and never tells WMS about a new mInputMethodInputTarget.

To address this, we clear mInputMethodInputTarget if it refers to a no longer existing
window, then the empty IME control target will take over, and hide the IME, which will
hide its dialog and let the newly launched WindowState obtain focus and ultimately
control of the IME.

Fixes: 160672060
Test: atest 'DisplayContentTests#testInputMethodInputTarget_isClearedWhenWindowStateIsRemoved'
Change-Id: I138ac7198013635e7fb620921305ed1eb224d4de
2 files changed