OSDN Git Service

Introduce @hide EditorInfo#targetInputMethodUser
authorYohei Yukawa <yukawa@google.com>
Fri, 18 Jan 2019 16:48:07 +0000 (08:48 -0800)
committerYohei Yukawa <yukawa@google.com>
Fri, 18 Jan 2019 16:48:07 +0000 (08:48 -0800)
commit0f5eade4a492fc91130da1aedcad0999932f4137
treeef70f8c6320be3346138512a2d88538bf19fda38
parentd70e1ad78882962c0e642d06138e7de2060ebce7
Introduce @hide EditorInfo#targetInputMethodUser

This is a preparation to propagate the expected IME user ID from
direct-reply notification to InputMethodManagerService (IMMS).

When per-profile IME mode [1] is enabled, IMMS basically assumes that
the IME user ID should be determined by calling process's user ID.
This works for most of apps, but does not work for direct-reply hosted
in the System UI process, which always runs as user 0.

With this CL, client apps can explicitly specify the target IME user
ID by using @hide field in EditorInfo.  For instance, to tell IMMS to
connect to user 10's IME, do this:

 @Override
 public InputConnection onCreateInputConnection(EditorInfo info) {
    InputConnection ic = super.onCreateInputConnection(info);
    info.targetInputMethodUser = UserHandle.of(10);  // user 10
    return ic;
 }

The calling process will receive SecurityException if it does not
belong to user 10 and does not have INTERACT_ACROSS_USERS_FULL.

This CL is just a preparation.  There should be no user-visible
behavior change yet.

 [1]: Ied99664d3dc61b97c919b220c601f90b29761b96
      a878b9500e6b89dce9738179edc27bcd0d736b7e

Bug: 120744418
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: Ia7ea944438d69669ccdf9111b34ba400e786a602
core/java/android/view/inputmethod/EditorInfo.java
core/java/com/android/internal/view/InputBindResult.java
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java