From 2c8068c98a96a5439d1fdd537eee1f1729f7fab4 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Sat, 10 Apr 2021 00:17:35 +0800 Subject: Consolidate InputMethodManager#toggleSoftInput reliability As previously InputMethodManager#toggleSoftInput is designed to tell InputMethodService directly through IInputMethodSession to toggle soft-keyboard visibility, this could be happened some unexpected IME visibility issues that when the app calling this method in the wrong state like the app toggling IME visibility when the app is off-screen but unexpectedly it ends up showing soft-keyboard when the IME is in invisible state. To minimize the app compatibility without changing the public API surface and reducing unexpected IME visibilty been toggled behavior especially happens when switching the apps, changed the internal IPC protocols to call IMMS#showSoftInput or IMMS#hideSoftInput directly according the previous IME consumer requested visibility state, so that in IMMS side can validate to see if the token user is still focused and ready to toggle the IME visibility to show or hide. As the result, we deprecated toggleSoftInput and toggleSoftInputFromWindow to state the reason as the above, and recommand to use showSoftInput or hideSoftInputFromWindow instead, so that framework side no longer has to call {InputMethodSessionWrapper, InputMethodSessionImpl}#toggleSoftInput. Bug: 182071625 Test: m checkapi doc-comment-check-docs Test: atest KeyboardVisibilityControlTest#testToggleSoftInput Change-Id: I390dc029e7bcc30c200926a9bfbbbd0268a1f714 --- core/api/current.txt | 8 ++-- .../IInputMethodSessionWrapper.java | 11 ----- .../inputmethodservice/InputMethodService.java | 8 +++- ...ultiClientInputMethodClientCallbackAdaptor.java | 19 -------- .../MultiClientInputMethodServiceDelegate.java | 10 ----- .../view/inputmethod/InputMethodManager.java | 52 ++++++++++++++++++---- .../view/inputmethod/InputMethodSession.java | 8 ++++ .../inputmethod/InputMethodSessionWrapper.java | 9 ---- .../internal/inputmethod/InputMethodDebug.java | 4 ++ .../inputmethod/SoftInputShowHideReason.java | 16 ++++++- .../android/internal/view/IInputMethodManager.aidl | 4 +- .../android/internal/view/IInputMethodSession.aidl | 2 - .../inputmethod/InputMethodManagerService.java | 20 ++++----- .../MultiClientInputMethodManagerService.java | 7 +-- 14 files changed, 98 insertions(+), 80 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index a2e0ed8a7a6a..36aff7e2e1d1 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -19314,7 +19314,7 @@ package android.inputmethodservice { method public void appPrivateCommand(String, android.os.Bundle); method public void displayCompletions(android.view.inputmethod.CompletionInfo[]); method public void finishInput(); - method public void toggleSoftInput(int, int); + method @Deprecated public void toggleSoftInput(int, int); method public void updateCursor(android.graphics.Rect); method public void updateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo); method public void updateExtractedText(int, android.view.inputmethod.ExtractedText); @@ -51999,8 +51999,8 @@ package android.view.inputmethod { method @Deprecated public void showStatusIcon(android.os.IBinder, String, @DrawableRes int); method @Deprecated public boolean switchToLastInputMethod(android.os.IBinder); method @Deprecated public boolean switchToNextInputMethod(android.os.IBinder, boolean); - method public void toggleSoftInput(int, int); - method public void toggleSoftInputFromWindow(android.os.IBinder, int, int); + method @Deprecated public void toggleSoftInput(int, int); + method @Deprecated public void toggleSoftInputFromWindow(android.os.IBinder, int, int); method @Deprecated public void updateCursor(android.view.View, int, int, int, int); method public void updateCursorAnchorInfo(android.view.View, android.view.inputmethod.CursorAnchorInfo); method public void updateExtractedText(android.view.View, int, android.view.inputmethod.ExtractedText); @@ -52023,7 +52023,7 @@ package android.view.inputmethod { method public void dispatchTrackballEvent(int, android.view.MotionEvent, android.view.inputmethod.InputMethodSession.EventCallback); method public void displayCompletions(android.view.inputmethod.CompletionInfo[]); method public void finishInput(); - method public void toggleSoftInput(int, int); + method @Deprecated public void toggleSoftInput(int, int); method public void updateCursor(android.graphics.Rect); method public void updateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo); method public void updateExtractedText(int, android.view.inputmethod.ExtractedText); diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java index 0766917642e8..5a517ee0b0eb 100644 --- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java +++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java @@ -49,7 +49,6 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub private static final int DO_UPDATE_CURSOR = 95; private static final int DO_UPDATE_CURSOR_ANCHOR_INFO = 99; private static final int DO_APP_PRIVATE_COMMAND = 100; - private static final int DO_TOGGLE_SOFT_INPUT = 105; private static final int DO_FINISH_SESSION = 110; private static final int DO_VIEW_CLICKED = 115; private static final int DO_NOTIFY_IME_HIDDEN = 120; @@ -123,10 +122,6 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub args.recycle(); return; } - case DO_TOGGLE_SOFT_INPUT: { - mInputMethodSession.toggleSoftInput(msg.arg1, msg.arg2); - return; - } case DO_FINISH_SESSION: { doFinishSession(); return; @@ -217,12 +212,6 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub mCaller.obtainMessageOO(DO_APP_PRIVATE_COMMAND, action, data)); } - @Override - public void toggleSoftInput(int showFlags, int hideFlags) { - mCaller.executeOrSendMessage( - mCaller.obtainMessageII(DO_TOGGLE_SOFT_INPUT, showFlags, hideFlags)); - } - @Override public void finishSession() { mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_FINISH_SESSION)); diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 5267aa81bdaf..4defc55fbd97 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -1042,8 +1042,14 @@ public class InputMethodService extends AbstractInputMethodService { } /** - * + * Handles a request to toggle the IME visibility. + * + * @deprecated Starting in {@link Build.VERSION_CODES#S} the system no longer invokes this + * method, instead it explicitly shows or hides the IME. An {@code InputMethodService} + * wishing to toggle its own visibility should instead invoke {@link + * InputMethodService#requestShowSelf} or {@link InputMethodService#requestHideSelf} */ + @Deprecated public void toggleSoftInput(int showFlags, int hideFlags) { InputMethodService.this.onToggleSoftInput(showFlags, hideFlags); } diff --git a/core/java/android/inputmethodservice/MultiClientInputMethodClientCallbackAdaptor.java b/core/java/android/inputmethodservice/MultiClientInputMethodClientCallbackAdaptor.java index 2db9ed1103fa..f352f05d0488 100644 --- a/core/java/android/inputmethodservice/MultiClientInputMethodClientCallbackAdaptor.java +++ b/core/java/android/inputmethodservice/MultiClientInputMethodClientCallbackAdaptor.java @@ -256,18 +256,6 @@ final class MultiClientInputMethodClientCallbackAdaptor { } } - @Override - public void toggleSoftInput(int showFlags, int hideFlags) { - synchronized (mSessionLock) { - if (mCallbackImpl == null || mHandler == null) { - return; - } - mHandler.sendMessage(PooledLambda.obtainMessage( - CallbackImpl::toggleSoftInput, mCallbackImpl, showFlags, - hideFlags)); - } - } - @Override public void finishSession() { synchronized (mSessionLock) { @@ -419,13 +407,6 @@ final class MultiClientInputMethodClientCallbackAdaptor { mOriginalCallback.onAppPrivateCommand(action, data); } - void toggleSoftInput(int showFlags, int hideFlags) { - if (mFinished) { - return; - } - mOriginalCallback.onToggleSoftInput(showFlags, hideFlags); - } - void finishSession() { if (mFinished) { return; diff --git a/core/java/android/inputmethodservice/MultiClientInputMethodServiceDelegate.java b/core/java/android/inputmethodservice/MultiClientInputMethodServiceDelegate.java index 4b02085726f1..0a2316508f09 100644 --- a/core/java/android/inputmethodservice/MultiClientInputMethodServiceDelegate.java +++ b/core/java/android/inputmethodservice/MultiClientInputMethodServiceDelegate.java @@ -165,16 +165,6 @@ public final class MultiClientInputMethodServiceDelegate { @SoftInputModeFlags int softInputMode, int targetWindowHandle); - /** - * Called when the associated IME client called {@link - * android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)}. - * - * @param showFlags The flag passed by the client. - * @param hideFlags The flag passed by the client. - * @see android.inputmethodservice.InputMethodService#onToggleSoftInput(int, int) - */ - void onToggleSoftInput(int showFlags, int hideFlags); - /** * Called when the associated IME client called {@link * android.view.inputmethod.InputMethodManager#updateCursorAnchorInfo(View, diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index d6292caba344..b5d6a5eca227 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -93,6 +93,7 @@ import com.android.internal.inputmethod.Completable; import com.android.internal.inputmethod.InputMethodDebug; import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry; import com.android.internal.inputmethod.ResultCallbacks; +import com.android.internal.inputmethod.SoftInputShowHideReason; import com.android.internal.inputmethod.StartInputFlags; import com.android.internal.inputmethod.StartInputReason; import com.android.internal.inputmethod.UnbindReason; @@ -1674,6 +1675,11 @@ public final class InputMethodManager { * {@link #RESULT_HIDDEN}. */ public boolean showSoftInput(View view, int flags, ResultReceiver resultReceiver) { + return showSoftInput(view, flags, resultReceiver, SoftInputShowHideReason.SHOW_SOFT_INPUT); + } + + private boolean showSoftInput(View view, int flags, ResultReceiver resultReceiver, + @SoftInputShowHideReason int reason) { ImeTracing.getInstance().triggerClientDump("InputMethodManager#showSoftInput", this, null /* icProto */); // Re-dispatch if there is a context mismatch. @@ -1697,6 +1703,7 @@ public final class InputMethodManager { view.getWindowToken(), flags, resultReceiver, + reason, ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { @@ -1731,6 +1738,7 @@ public final class InputMethodManager { mCurRootView.getView().getWindowToken(), flags, resultReceiver, + SoftInputShowHideReason.SHOW_SOFT_INPUT, ResultCallbacks.of(value)); Completable.getResult(value); // ignore the result } catch (RemoteException e) { @@ -1795,6 +1803,12 @@ public final class InputMethodManager { */ public boolean hideSoftInputFromWindow(IBinder windowToken, int flags, ResultReceiver resultReceiver) { + return hideSoftInputFromWindow(windowToken, flags, resultReceiver, + SoftInputShowHideReason.HIDE_SOFT_INPUT); + } + + private boolean hideSoftInputFromWindow(IBinder windowToken, int flags, + ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { ImeTracing.getInstance().triggerClientDump("InputMethodManager#hideSoftInputFromWindow", this, null /* icProto */); checkFocus(); @@ -1806,8 +1820,8 @@ public final class InputMethodManager { try { final Completable.Boolean value = Completable.createBoolean(); - mService.hideSoftInput( - mClient, windowToken, flags, resultReceiver, ResultCallbacks.of(value)); + mService.hideSoftInput(mClient, windowToken, flags, resultReceiver, reason, + ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); @@ -1827,7 +1841,14 @@ public final class InputMethodManager { * @param hideFlags Provides additional operating flags. May be * 0 or have the {@link #HIDE_IMPLICIT_ONLY}, * {@link #HIDE_NOT_ALWAYS} bit set. - **/ + * + * @deprecated Use {@link #showSoftInput(View, int)} or + * {@link #hideSoftInputFromWindow(IBinder, int)} explicitly instead. + * In particular during focus changes, the current visibility of the IME is not + * well defined. Starting in {@link Build.VERSION_CODES#S Android S}, this only + * has an effect if the calling app is the current IME focus. + */ + @Deprecated public void toggleSoftInputFromWindow(IBinder windowToken, int showFlags, int hideFlags) { ImeTracing.getInstance().triggerClientDump( "InputMethodManager#toggleSoftInputFromWindow", InputMethodManager.this, @@ -1837,9 +1858,7 @@ public final class InputMethodManager { if (servedView == null || servedView.getWindowToken() != windowToken) { return; } - if (mCurrentInputMethodSession != null) { - mCurrentInputMethodSession.toggleSoftInput(showFlags, hideFlags); - } + toggleSoftInput(showFlags, hideFlags); } } @@ -1854,13 +1873,29 @@ public final class InputMethodManager { * @param hideFlags Provides additional operating flags. May be * 0 or have the {@link #HIDE_IMPLICIT_ONLY}, * {@link #HIDE_NOT_ALWAYS} bit set. + * + * @deprecated Use {@link #showSoftInput(View, int)} or + * {@link #hideSoftInputFromWindow(IBinder, int)} explicitly instead. + * In particular during focus changes, the current visibility of the IME is not + * well defined. Starting in {@link Build.VERSION_CODES#S Android S}, this only + * has an effect if the calling app is the current IME focus. */ + @Deprecated public void toggleSoftInput(int showFlags, int hideFlags) { ImeTracing.getInstance().triggerClientDump( "InputMethodManager#toggleSoftInput", InputMethodManager.this, null /* icProto */); - if (mCurrentInputMethodSession != null) { - mCurrentInputMethodSession.toggleSoftInput(showFlags, hideFlags); + synchronized (mH) { + final View view = getServedViewLocked(); + if (mImeInsetsConsumer != null && view != null) { + if (mImeInsetsConsumer.isRequestedVisible()) { + hideSoftInputFromWindow(view.getWindowToken(), hideFlags, null, + SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT); + } else { + showSoftInput(view, showFlags, null, + SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT); + } + } } } @@ -2144,6 +2179,7 @@ public final class InputMethodManager { mCurRootView.getView().getWindowToken(), HIDE_NOT_ALWAYS, null, + SoftInputShowHideReason.HIDE_SOFT_INPUT, ResultCallbacks.of(value)); Completable.getResult(value); // ignore the result } catch (RemoteException e) { diff --git a/core/java/android/view/inputmethod/InputMethodSession.java b/core/java/android/view/inputmethod/InputMethodSession.java index 0d688ffa44c8..52c1cd4f628a 100644 --- a/core/java/android/view/inputmethod/InputMethodSession.java +++ b/core/java/android/view/inputmethod/InputMethodSession.java @@ -17,6 +17,8 @@ package android.view.inputmethod; import android.graphics.Rect; +import android.inputmethodservice.InputMethodService; +import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; import android.view.MotionEvent; @@ -172,7 +174,13 @@ public interface InputMethodSession { * @param hideFlags Provides additional operating flags. May be * 0 or have the {@link InputMethodManager#HIDE_IMPLICIT_ONLY}, * {@link InputMethodManager#HIDE_NOT_ALWAYS} bit set. + * + * @deprecated Starting in {@link Build.VERSION_CODES#S} the system no longer invokes this + * method, instead it explicitly shows or hides the IME. An {@code InputMethodService} + * wishing to toggle its own visibility should instead invoke {@link + * InputMethodService#requestShowSelf} or {@link InputMethodService#requestHideSelf} */ + @Deprecated public void toggleSoftInput(int showFlags, int hideFlags); /** diff --git a/core/java/android/view/inputmethod/InputMethodSessionWrapper.java b/core/java/android/view/inputmethod/InputMethodSessionWrapper.java index c4a3773f87e3..ef1814b7bdf2 100644 --- a/core/java/android/view/inputmethod/InputMethodSessionWrapper.java +++ b/core/java/android/view/inputmethod/InputMethodSessionWrapper.java @@ -95,15 +95,6 @@ final class InputMethodSessionWrapper { } } - @AnyThread - void toggleSoftInput(int showFlags, int hideFlags) { - try { - mSession.toggleSoftInput(showFlags, hideFlags); - } catch (RemoteException e) { - Log.w(TAG, "IME died", e); - } - } - @AnyThread void appPrivateCommand(String action, Bundle data) { try { diff --git a/core/java/com/android/internal/inputmethod/InputMethodDebug.java b/core/java/com/android/internal/inputmethod/InputMethodDebug.java index 93374ba0cf46..d026ecda346a 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodDebug.java +++ b/core/java/com/android/internal/inputmethod/InputMethodDebug.java @@ -230,6 +230,10 @@ public final class InputMethodDebug { return "HIDE_REMOVE_CLIENT"; case SoftInputShowHideReason.SHOW_RESTORE_IME_VISIBILITY: return "SHOW_RESTORE_IME_VISIBILITY"; + case SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT: + return "SHOW_TOGGLE_SOFT_INPUT"; + case SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT: + return "HIDE_TOGGLE_SOFT_INPUT"; default: return "Unknown=" + reason; } diff --git a/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java b/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java index f1cdf2b38c4c..755bd5e1df31 100644 --- a/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java +++ b/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java @@ -50,7 +50,9 @@ import java.lang.annotation.Retention; SoftInputShowHideReason.HIDE_BUBBLES, SoftInputShowHideReason.HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR, SoftInputShowHideReason.HIDE_REMOVE_CLIENT, - SoftInputShowHideReason.SHOW_RESTORE_IME_VISIBILITY}) + SoftInputShowHideReason.SHOW_RESTORE_IME_VISIBILITY, + SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT, + SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT}) public @interface SoftInputShowHideReason { /** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */ int SHOW_SOFT_INPUT = 0; @@ -174,4 +176,16 @@ public @interface SoftInputShowHideReason { * {@link com.android.server.wm.WindowManagerInternal#shouldRestoreImeVisibility}. */ int SHOW_RESTORE_IME_VISIBILITY = 22; + + /** + * Show soft input by + * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)}; + */ + int SHOW_TOGGLE_SOFT_INPUT = 23; + + /** + * Hide soft input by + * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)}; + */ + int HIDE_TOGGLE_SOFT_INPUT = 24; } diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl index 93cd4e9046c6..a67b785cf0fd 100644 --- a/core/java/com/android/internal/view/IInputMethodManager.aidl +++ b/core/java/com/android/internal/view/IInputMethodManager.aidl @@ -52,9 +52,9 @@ interface IInputMethodManager { oneway void getLastInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback); oneway void showSoftInput(in IInputMethodClient client, IBinder windowToken, int flags, - in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback); + in ResultReceiver resultReceiver, int reason, in IBooleanResultCallback resultCallback); oneway void hideSoftInput(in IInputMethodClient client, IBinder windowToken, int flags, - in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback); + in ResultReceiver resultReceiver, int reason, in IBooleanResultCallback resultCallback); // If windowToken is null, this just does startInput(). Otherwise this reports that a window // has gained focus, and if 'attribute' is non-null then also does startInput. // @NonNull diff --git a/core/java/com/android/internal/view/IInputMethodSession.aidl b/core/java/com/android/internal/view/IInputMethodSession.aidl index c6afd78ec04b..acb4754886ab 100644 --- a/core/java/com/android/internal/view/IInputMethodSession.aidl +++ b/core/java/com/android/internal/view/IInputMethodSession.aidl @@ -43,8 +43,6 @@ oneway interface IInputMethodSession { void appPrivateCommand(String action, in Bundle data); - void toggleSoftInput(int showFlags, int hideFlags); - void finishSession(); void updateCursorAnchorInfo(in CursorAnchorInfo cursorAnchorInfo); diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 3424821495c5..75c24268d0af 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -3143,7 +3143,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public void showSoftInput(IInputMethodClient client, IBinder windowToken, int flags, - ResultReceiver resultReceiver, IBooleanResultCallback resultCallback) { + ResultReceiver resultReceiver, @SoftInputShowHideReason int reason, + IBooleanResultCallback resultCallback) { CallbackUtils.onResult(resultCallback, () -> { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showSoftInput"); int uid = Binder.getCallingUid(); @@ -3172,8 +3173,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } if (DEBUG) Slog.v(TAG, "Client requesting input be shown"); - return showCurrentInputLocked(windowToken, flags, resultReceiver, - SoftInputShowHideReason.SHOW_SOFT_INPUT); + return showCurrentInputLocked(windowToken, flags, resultReceiver, reason); } finally { Binder.restoreCallingIdentity(ident); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); @@ -3262,7 +3262,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public void hideSoftInput(IInputMethodClient client, IBinder windowToken, int flags, - ResultReceiver resultReceiver, IBooleanResultCallback resultCallback) { + ResultReceiver resultReceiver, @SoftInputShowHideReason int reason, + IBooleanResultCallback resultCallback) { CallbackUtils.onResult(resultCallback, () -> { int uid = Binder.getCallingUid(); ImeTracing.getInstance().triggerManagerServiceDump( @@ -3296,8 +3297,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (DEBUG) Slog.v(TAG, "Client requesting input be hidden"); return InputMethodManagerService.this.hideCurrentInputLocked(windowToken, - flags, resultReceiver, - SoftInputShowHideReason.HIDE_SOFT_INPUT); + flags, resultReceiver, reason); } finally { Binder.restoreCallingIdentity(ident); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); @@ -3326,8 +3326,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // since Android Eclair. That's why we need to accept IMM#hideSoftInput() even when only // IMMS#InputShown indicates that the software keyboard is shown. // TODO: Clean up, IMMS#mInputShown, IMMS#mImeWindowVis and mShowRequested. - final boolean shouldHideSoftInput = (mCurMethod != null) && (mInputShown || - (mImeWindowVis & InputMethodService.IME_ACTIVE) != 0); + final boolean shouldHideSoftInput = (mCurMethod != null) && (mInputShown + || (mImeWindowVis & InputMethodService.IME_ACTIVE) != 0); boolean res; if (shouldHideSoftInput) { final Binder hideInputToken = new Binder(); @@ -4444,7 +4444,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub ((IInputMethod) args.arg1).showSoftInput( (IBinder) args.arg3, msg.arg1, (ResultReceiver) args.arg2); mSoftInputShowHideHistory.addEntry(new SoftInputShowHideHistory.Entry( - mCurClient, mCurAttribute, + mCurFocusedWindowClient, mCurAttribute, mWindowManagerInternal.getWindowName(mCurFocusedWindow), mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode, mWindowManagerInternal.getWindowName( @@ -4467,7 +4467,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub ((IInputMethod)args.arg1).hideSoftInput( (IBinder) args.arg3, 0, (ResultReceiver)args.arg2); mSoftInputShowHideHistory.addEntry(new SoftInputShowHideHistory.Entry( - mCurClient, mCurAttribute, + mCurFocusedWindowClient, mCurAttribute, mWindowManagerInternal.getWindowName(mCurFocusedWindow), mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode, mWindowManagerInternal.getWindowName( diff --git a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java index fcaf6d8fe400..c47f9e56a059 100644 --- a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java @@ -1521,8 +1521,8 @@ public final class MultiClientInputMethodManagerService { @BinderThread @Override public void showSoftInput( - IInputMethodClient client, IBinder token, int flags, - ResultReceiver resultReceiver, IBooleanResultCallback resultCallback) { + IInputMethodClient client, IBinder token, int flags, ResultReceiver resultReceiver, + @SoftInputShowHideReason int reason, IBooleanResultCallback resultCallback) { CallbackUtils.onResult(resultCallback, () -> showSoftInputInternal(client, token, flags, resultReceiver)); } @@ -1577,7 +1577,8 @@ public final class MultiClientInputMethodManagerService { @Override public void hideSoftInput( IInputMethodClient client, IBinder windowToken, int flags, - ResultReceiver resultReceiver, IBooleanResultCallback resultCallback) { + ResultReceiver resultReceiver, @SoftInputShowHideReason int reason, + IBooleanResultCallback resultCallback) { CallbackUtils.onResult(resultCallback, () -> hideSoftInputInternal(client, windowToken, flags, resultReceiver)); -- cgit v1.2.3-59-g8ed1b