Make ACTION_CLOSE_SYSTEM_DIALOGS handler in IMMS multi-user-aware

This is something we have completely overlooked when
InputMethodManagerService (IMMS) is upgraded to multi-user-aware [1].

Currently IMMS monitors ACTION_CLOSE_SYSTEM_DIALOGS sent to the system
user (usually user 0) only, if the IME switcher dialog cannot be
dismissed when:
 * the current user is a secondary user, and
 * a secondary user process sends ACTION_CLOSE_SYSTEM_DIALOGS,
which is not an intentional behavior.

With this CL, ACTION_CLOSE_SYSTEM_DIALOGS handler in IMMS becomes
multi-user-aware and accepts only if it is sent to the current user.

 [1]: Ib23849d352db33f0747aa9d5a178f00ac726c13b
      4e1ab15b305aac26ad8819fc3b2951e20985944d

Fix: 127810562
Test: Manually verified as follows.
   1. Build aosp_blueline-userdebug and flash it.
   2. adb shell pm create-user test_user
   3. adb shell am switch-user 10
   4. adb shell wm dismiss-keyguard
   5. atest android.view.inputmethod.cts.InputMethodManagerTest#testShowInputMethodPicker
Test: Manually verified as follows.
   1. Build aosp_blueline-userdebug and flash it.
   2. adb shell pm create-user test_user
   3. adb shell am switch-user 10
   4. adb shell wm dismiss-keyguard
   5. make -j SoftKeyboard
   6. adb install -r $OUT/system/app/SoftKeyboard/SoftKeyboard.apk
   7. adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard
   8. Tap the search field of the launcher.
   9. Make sure AOSP Keyboard is shown.
  10. Tap the IME switcher icon on the navigation bar.
  11. Make sure IME switcher dialog is shown.
  12. adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS --user 0
  13. Make sure that the IME switcher dialog is not dismissed.
  14. adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS --user 10
  15. Make sure that the IME switcher dialog is dismissed.
  16. Tap the IME switcher icon on the navigation bar again.
  17. Make sure IME switcher dialog is shown.
  18. adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS --user all
  19. Make sure that the IME switcher dialog is dismissed.
  20. Tap the IME switcher icon on the navigation bar again.
  21. Make sure IME switcher dialog is shown.
  22. adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS --user current
  23. Make sure that the IME switcher dialog is dismissed.
Change-Id: Id71e6f8122be05e27545fa9d6b95a0b6156d202c
1 file changed