Skip to content
Commit 716897ce authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Harden caller verification in IMMS#startInputOrWindowGainedFocus()

Previously, privileged processes (w/ INTERACT_ACROSS_USERS_FULL) that
run as user X are automatically allowed to connect to the current IME
even when it runs as a different user Y.

However, as explained in my previous CL [1], there are many text
operations that are already fully multiuser-aware hence need to be
connected to the right user's services.

If EditorInfo#targetInputMethodUser [2] is not correctly set when it
should have been, it's highly likely that the IME client would need to
call TextView#setTextOperationUser() [3] as I did for System UI [1].

To detect such problems as early as possible, with this CL
IMMS#startInputOrWindowGainedFocus() no longer resolves null
EditorInfo#targetInputMethodUser as the current IME user for
privileged processes that have INTERACT_ACROSS_USERS_FULL permission.

If this CL broke some IME use case, most likely the IME client app
would need to be fixed.

 [1]: Ibabe13e5b85e5bb91f9f8af6ec07c395c25c4393
      7276946b
 [2]: Ia7ea944438d69669ccdf9111b34ba400e786a602
      0f5eade4
 [3]: I6d11e4d6a84570bc2991a8552349e8b216b0d139
      401e3d4c

Bug: 34886274
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Test: per-profile mode still works.
Test: Manually tested multi-user scenario as follows
  1. Build and flash an AOSP build
  2. Create a secondary user then switch to it.
  3. make -j SoftKeyboard
  4. adb install -r $OUT/system/app/SoftKeyboard/SoftKeyboard.apk
  5. adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard
  6. adb shell ime set com.example.android.softkeyboard/.SoftKeyboard
  7. make -j EditTextVariations
  8. adb install -r $ANDROID_TARGET_OUT_TESTCASES/EditTextVariations/EditTextVariations.apk
  9. adb shell am start \
     -n com.android.inputmethod.tools.edittextvariations/.EditTextVariations
 10. Tap the menu icon on the EditTextVariations then click "Direct Reply"
 11. Tap reply icon on "Message from UserHandle{10}".
 12. Make sure that SoftKeyboard Sample IME is shown.
 13. Type "ggggg" then hit the space key.
 14. Make sure that red underline is drawn under "ggggg"
 15. Make sure that AndroidSpellCheckerService runs as user 10.
 16. Set up a text screenlock.
 17. Turn off the display.
 18. Turn on the display.
 19. Make sure that SoftKeyboard Sample IME is shown.
Change-Id: Ieb94ed14698ee2669adc5fb2ea0e93c7d0e09e8b
parent 3dc17243
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