diff --git a/core/java/com/android/internal/view/InputBindResult.java b/core/java/com/android/internal/view/InputBindResult.java index 7548c2257c066..101fd41f29252 100644 --- a/core/java/com/android/internal/view/InputBindResult.java +++ b/core/java/com/android/internal/view/InputBindResult.java @@ -139,8 +139,7 @@ public final class InputBindResult implements Parcelable { * The client should try to restart input when its {@link android.view.Window} is focused * again.

* - * @see com.android.server.wm.WindowManagerInternal#inputMethodClientHasFocus( - * IInputMethodClient) + * @see com.android.server.wm.WindowManagerInternal#isInputMethodClientFocus(int, int) */ int ERROR_NOT_IME_TARGET_WINDOW = 11; /** diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index b2287acc635a5..a043201100bde 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -2536,7 +2536,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // We need to check if this is the current client with // focus in the window manager, to allow this call to // be made before input is started in it. - if (!mWindowManagerInternal.inputMethodClientHasFocus(client)) { + final ClientState cs = mClients.get(client.asBinder()); + if (cs == null) { + throw new IllegalArgumentException("unknown client " + client.asBinder()); + } + if (!mWindowManagerInternal.isInputMethodClientFocus(cs.uid, cs.pid)) { Slog.w(TAG, "Ignoring showSoftInput of uid " + uid + ": " + client); return false; } @@ -2616,7 +2620,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // We need to check if this is the current client with // focus in the window manager, to allow this call to // be made before input is started in it. - if (!mWindowManagerInternal.inputMethodClientHasFocus(client)) { + final ClientState cs = mClients.get(client.asBinder()); + if (cs == null) { + throw new IllegalArgumentException("unknown client " + client.asBinder()); + } + if (!mWindowManagerInternal.isInputMethodClientFocus(cs.uid, cs.pid)) { if (DEBUG) { Slog.w(TAG, "Ignoring hideSoftInput of uid " + uid + ": " + client); } @@ -2734,7 +2742,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub + client.asBinder()); } - if (!mWindowManagerInternal.inputMethodClientHasFocus(cs.client)) { + if (!mWindowManagerInternal.isInputMethodClientFocus(cs.uid, cs.pid)) { // Check with the window manager to make sure this client actually // has a window with focus. If not, reject. This is thread safe // because if the focus changes some time before or after, the diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 6c7304dc052fc..d518549859a0b 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -150,7 +150,6 @@ import android.view.SurfaceSession; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ToBooleanFunction; -import com.android.internal.view.IInputMethodClient; import com.android.server.policy.WindowManagerPolicy; import com.android.server.wm.utils.RotationCache; import com.android.server.wm.utils.WmDisplayCutout; @@ -2949,7 +2948,7 @@ class DisplayContent extends WindowContainer= 0; --i) { final DisplayContent displayContent = mRoot.mChildren.get(i); - if (displayContent.inputMethodClientHasFocus(client)) { + if (displayContent.isInputMethodClientFocus(uid, pid)) { return true; } } @@ -7430,8 +7430,8 @@ public class WindowManagerService extends IWindowManager.Stub // press home. Sometimes the IME won't go down.) // Would be nice to fix this more correctly, but it's // way at the end of a release, and this should be good enough. - if (mCurrentFocus != null && mCurrentFocus.mSession.mClient != null - && mCurrentFocus.mSession.mClient.asBinder() == client.asBinder()) { + if (mCurrentFocus != null && mCurrentFocus.mSession.mUid == uid + && mCurrentFocus.mSession.mPid == pid) { return true; } }