Skip to content
Commit 32807ad5 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Fix session race due to pending user-switch task

This is a follow up CL to my previous CL [1], which aimed to optimize
InputMethodManagerService#startInputOrWindowGainedFocus() by
introducing UserSwitchHandlerTask to minimize the wall time consumed
there so that we can unblock IME target's UI thread as soon as
possible.  To make it work, InputMethodManagerService (IMMS) now needs
to check whether there is any pending UserSwitchHandlerTask or not
when dealing with incoming calls such as another IMMS#onSwitchUser.

My previous CL updated most of the cases correctly, but it turns out
that I overlooked IMMS#onSessionCreated(), which can also be called
asynchronously.  As a result, an app running for user X might end up
being connected to an IME running as user Y, which is not OK.

With this CL, any IMMS#onSessionCreated() will simply be ignored when
there is a pending UserSwitchHandlerTask, because it means that the
callback is from the previously used IME, which will soon be destroyed
because IMMS is now switching to a different user.

 [1]: I5a73a66d2b8acadad9b3577ebc4c17b5a25fd011
      d277d690

Bug: 139806621
Fix: 150235502
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: Ia530df401645a979d983b8eb262dcba23eff4fbd
parent 896f664c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment