diff options
| -rw-r--r-- | core/java/android/view/inputmethod/EditorInfo.java | 10 | ||||
| -rw-r--r-- | services/core/java/com/android/server/inputmethod/InputMethodManagerService.java | 13 |
2 files changed, 9 insertions, 14 deletions
diff --git a/core/java/android/view/inputmethod/EditorInfo.java b/core/java/android/view/inputmethod/EditorInfo.java index f99afe6cdab9..8e7b0db21946 100644 --- a/core/java/android/view/inputmethod/EditorInfo.java +++ b/core/java/android/view/inputmethod/EditorInfo.java @@ -479,13 +479,9 @@ public class EditorInfo implements InputType, Parcelable { * If not {@code null}, this editor needs to talk to IMEs that run for the specified user, no * matter what user ID the calling process has. * - * <p>Note: This field is silently ignored when:</p> - * <ul> - * <li>{@link android.view.inputmethod.InputMethodSystemProperty#PER_PROFILE_IME_ENABLED} is - * {@code false}.</li> - * <li>{@link android.view.inputmethod.InputMethodSystemProperty#MULTI_CLIENT_IME_ENABLED} - * is {@code true}.</li> - * </ul> + * <p>Note: This field will be silently ignored when + * {@link android.view.inputmethod.InputMethodSystemProperty#MULTI_CLIENT_IME_ENABLED} is + * {@code true}.</p> * * <p>Note also that pseudo handles such as {@link UserHandle#ALL} are not supported.</p> * diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 6c3cc58a1bd6..2d197bb4da96 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -2845,7 +2845,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub int unverifiedTargetSdkVersion) { final int callingUserId = UserHandle.getCallingUserId(); final int userId; - if (PER_PROFILE_IME_ENABLED && attribute != null && attribute.targetInputMethodUser != null + if (attribute != null && attribute.targetInputMethodUser != null && attribute.targetInputMethodUser.getIdentifier() != callingUserId) { mContext.enforceCallingPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL, "Using EditorInfo.user requires INTERACT_ACROSS_USERS_FULL."); @@ -2862,9 +2862,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } InputBindResult res = null; synchronized (mMethodMap) { - // Needs to check the validity before clearing calling identity - // Note that cross-profile access is always allowed here to allow profile-switching. - final boolean calledFromValidUser = calledFromValidUserLocked(true); final int windowDisplayId = mWindowManagerInternal.getDisplayIdForWindow(windowToken); final long ident = Binder.clearCallingIdentity(); @@ -2908,10 +2905,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return InputBindResult.NOT_IME_TARGET_WINDOW; } - if (!calledFromValidUser) { + // cross-profile access is always allowed here to allow profile-switching. + if (!mSettings.isCurrentProfile(userId)) { Slog.w(TAG, "A background user is requesting window. Hiding IME."); - Slog.w(TAG, "If you want to interect with IME, you need " - + "android.permission.INTERACT_ACROSS_USERS_FULL"); + Slog.w(TAG, "If you need to impersonate a foreground user/profile from" + + " a background user, use EditorInfo.targetInputMethodUser with" + + " INTERACT_ACROSS_USERS_FULL permission."); hideCurrentInputLocked(0, null); return InputBindResult.INVALID_USER; } |