Set mNextServedView as null only when current served view lost focus

mNextServedView is set to null when the next view focus is lost.
but we should not set mNextServedView as null when received the
next view focus is lost but the view is not the current served view.

It can happen when received next view focused but input connection will
disconnect when mNextServidedView is null.

The issue is found when the Activity has ListView which added SearchView
as a list item.

When the Activity is launched, input connection will be started when
activity window focused and served view will be SearchView since search
view request focus by default, then when user taps SearchView,

several view focus in/out events comes out quickly that may cause
mNextServedView set to null when the conteiner View lost focus, so input
connection will be disconnected since ImeFocusController#checkFocus checked
there is no next served view.

The fix is to set mNextServedView as null only when the current served view
loses focus.

Fix: 148974380
Test: atest FocusHandlingTests
Change-Id: I9e90428387fcf43fbf86a8407de7535913202872
1 file changed