Loading core/java/android/inputmethodservice/IInputMethodWrapper.java +15 −8 Original line number Diff line number Diff line Loading @@ -219,22 +219,29 @@ class IInputMethodWrapper extends IInputMethod.Stub case DO_REVOKE_SESSION: inputMethod.revokeSession((InputMethodSession)msg.obj); return; case DO_SHOW_SOFT_INPUT: SomeArgs args = (SomeArgs)msg.obj; case DO_SHOW_SOFT_INPUT: { final SomeArgs args = (SomeArgs)msg.obj; inputMethod.showSoftInputWithToken( msg.arg1, (ResultReceiver) args.arg2, (IBinder) args.arg1); args.recycle(); return; case DO_HIDE_SOFT_INPUT: inputMethod.hideSoftInput(msg.arg1, (ResultReceiver)msg.obj); } case DO_HIDE_SOFT_INPUT: { final SomeArgs args = (SomeArgs) msg.obj; inputMethod.hideSoftInputWithToken(msg.arg1, (ResultReceiver) args.arg2, (IBinder) args.arg1); args.recycle(); return; } case DO_CHANGE_INPUTMETHOD_SUBTYPE: inputMethod.changeInputMethodSubtype((InputMethodSubtype)msg.obj); return; case DO_CREATE_INLINE_SUGGESTIONS_REQUEST: args = (SomeArgs) msg.obj; final SomeArgs args = (SomeArgs) msg.obj; inputMethod.onCreateInlineSuggestionsRequest( (InlineSuggestionsRequestInfo) args.arg1, (IInlineSuggestionsRequestCallback) args.arg2); args.recycle(); return; } Loading Loading @@ -380,9 +387,9 @@ class IInputMethodWrapper extends IInputMethod.Stub @BinderThread @Override public void hideSoftInput(int flags, ResultReceiver resultReceiver) { mCaller.executeOrSendMessage(mCaller.obtainMessageIO(DO_HIDE_SOFT_INPUT, flags, resultReceiver)); public void hideSoftInput(IBinder hideInputToken, int flags, ResultReceiver resultReceiver) { mCaller.executeOrSendMessage(mCaller.obtainMessageIOO(DO_HIDE_SOFT_INPUT, flags, hideInputToken, resultReceiver)); } @BinderThread Loading core/java/android/inputmethodservice/InputMethodService.java +43 −1 Original line number Diff line number Diff line Loading @@ -459,6 +459,16 @@ public class InputMethodService extends AbstractInputMethodService { */ private IBinder mCurShowInputToken; /** * An opaque {@link Binder} token of window requesting {@link InputMethodImpl#hideSoftInput} * The original app window token is passed from client app window. * {@link com.android.server.inputmethod.InputMethodManagerService} creates a unique dummy * token to identify this window. * This dummy token is only valid for a single call to {@link InputMethodImpl#hideSoftInput}, * after which it is set {@code null} until next call. */ private IBinder mCurHideInputToken; final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> { onComputeInsets(mTmpInsets); if (isExtractViewShown()) { Loading Loading @@ -500,6 +510,7 @@ public class InputMethodService extends AbstractInputMethodService { public class InputMethodImpl extends AbstractInputMethodImpl { private boolean mSystemCallingShowSoftInput; private boolean mSystemCallingHideSoftInput; /** * {@inheritDoc} Loading Loading @@ -634,6 +645,21 @@ public class InputMethodService extends AbstractInputMethodService { } } /** * {@inheritDoc} * @hide */ @MainThread @Override public void hideSoftInputWithToken(int flags, ResultReceiver resultReceiver, IBinder hideInputToken) { mSystemCallingHideSoftInput = true; mCurHideInputToken = hideInputToken; hideSoftInput(flags, resultReceiver); mCurHideInputToken = null; mSystemCallingHideSoftInput = false; } /** * {@inheritDoc} */ Loading @@ -641,6 +667,12 @@ public class InputMethodService extends AbstractInputMethodService { @Override public void hideSoftInput(int flags, ResultReceiver resultReceiver) { if (DEBUG) Log.v(TAG, "hideSoftInput()"); if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.R && !mSystemCallingHideSoftInput) { Log.e(TAG, "IME shouldn't call hideSoftInput on itself." + " Use requestHideSelf(int) itself"); return; } final boolean wasVisible = mIsPreRendered ? mDecorViewVisible && mWindowVisible : isInputViewShown(); applyVisibilityInInsetsConsumerIfNecessary(false /* setVisible */); Loading Loading @@ -738,6 +770,15 @@ public class InputMethodService extends AbstractInputMethodService { public void setCurrentShowInputToken(IBinder showInputToken) { mCurShowInputToken = showInputToken; } /** * {@inheritDoc} * @hide */ @Override public void setCurrentHideInputToken(IBinder hideInputToken) { mCurHideInputToken = hideInputToken; } } // TODO(b/137800469): Add detailed docs explaining the inline suggestions process. Loading Loading @@ -2172,7 +2213,8 @@ public class InputMethodService extends AbstractInputMethodService { if (!isVisibilityAppliedUsingInsetsConsumer()) { return; } mPrivOps.applyImeVisibility(mCurShowInputToken, setVisible); mPrivOps.applyImeVisibility(setVisible ? mCurShowInputToken : mCurHideInputToken, setVisible); } private boolean isVisibilityAppliedUsingInsetsConsumer() { Loading core/java/android/view/inputmethod/InputMethod.java +30 −0 Original line number Diff line number Diff line Loading @@ -348,6 +348,27 @@ public interface InputMethod { * {@link InputMethodManager#RESULT_UNCHANGED_HIDDEN InputMethodManager.RESULT_UNCHANGED_HIDDEN}, * {@link InputMethodManager#RESULT_SHOWN InputMethodManager.RESULT_SHOWN}, or * {@link InputMethodManager#RESULT_HIDDEN InputMethodManager.RESULT_HIDDEN}. * @param hideInputToken an opaque {@link android.os.Binder} token to identify which API call * of {@link InputMethodManager#hideSoftInputFromWindow(IBinder, int)}} is associated * with this callback. * @hide */ @MainThread public void hideSoftInputWithToken(int flags, ResultReceiver resultReceiver, IBinder hideInputToken); /** * Request that any soft input part of the input method be hidden from the user. * @param flags Provides additional information about the show request. * Currently always 0. * @param resultReceiver The client requesting the show may wish to * be told the impact of their request, which should be supplied here. * The result code should be * {@link InputMethodManager#RESULT_UNCHANGED_SHOWN InputMethodManager.RESULT_UNCHANGED_SHOWN}, * {@link InputMethodManager#RESULT_UNCHANGED_HIDDEN * InputMethodManager.RESULT_UNCHANGED_HIDDEN}, * {@link InputMethodManager#RESULT_SHOWN InputMethodManager.RESULT_SHOWN}, or * {@link InputMethodManager#RESULT_HIDDEN InputMethodManager.RESULT_HIDDEN}. */ @MainThread public void hideSoftInput(int flags, ResultReceiver resultReceiver); Loading @@ -366,4 +387,13 @@ public interface InputMethod { * @hide */ public void setCurrentShowInputToken(IBinder showInputToken); /** * Update token of the client window requesting {@link #hideSoftInput(int, ResultReceiver)} * @param hideInputToken dummy app window token for window requesting * {@link InputMethodManager#hideSoftInputFromWindow(IBinder, int)} * @hide */ public void setCurrentHideInputToken(IBinder hideInputToken); } core/java/android/view/inputmethod/InputMethodManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -1709,7 +1709,7 @@ public final class InputMethodManager { } try { return mService.hideSoftInput(mClient, flags, resultReceiver); return mService.hideSoftInput(mClient, windowToken, flags, resultReceiver); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -1986,7 +1986,8 @@ public final class InputMethodManager { @UnsupportedAppUsage void closeCurrentInput() { try { mService.hideSoftInput(mClient, HIDE_NOT_ALWAYS, null); mService.hideSoftInput( mClient, mCurRootView.getView().getWindowToken(), HIDE_NOT_ALWAYS, null); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/com/android/internal/inputmethod/IInputMethodPrivilegedOperations.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -41,5 +41,5 @@ interface IInputMethodPrivilegedOperations { boolean shouldOfferSwitchingToNextInputMethod(); void notifyUserAction(); void reportPreRendered(in EditorInfo info); void applyImeVisibility(IBinder showInputToken, boolean setVisible); void applyImeVisibility(IBinder showOrHideInputToken, boolean setVisible); } Loading
core/java/android/inputmethodservice/IInputMethodWrapper.java +15 −8 Original line number Diff line number Diff line Loading @@ -219,22 +219,29 @@ class IInputMethodWrapper extends IInputMethod.Stub case DO_REVOKE_SESSION: inputMethod.revokeSession((InputMethodSession)msg.obj); return; case DO_SHOW_SOFT_INPUT: SomeArgs args = (SomeArgs)msg.obj; case DO_SHOW_SOFT_INPUT: { final SomeArgs args = (SomeArgs)msg.obj; inputMethod.showSoftInputWithToken( msg.arg1, (ResultReceiver) args.arg2, (IBinder) args.arg1); args.recycle(); return; case DO_HIDE_SOFT_INPUT: inputMethod.hideSoftInput(msg.arg1, (ResultReceiver)msg.obj); } case DO_HIDE_SOFT_INPUT: { final SomeArgs args = (SomeArgs) msg.obj; inputMethod.hideSoftInputWithToken(msg.arg1, (ResultReceiver) args.arg2, (IBinder) args.arg1); args.recycle(); return; } case DO_CHANGE_INPUTMETHOD_SUBTYPE: inputMethod.changeInputMethodSubtype((InputMethodSubtype)msg.obj); return; case DO_CREATE_INLINE_SUGGESTIONS_REQUEST: args = (SomeArgs) msg.obj; final SomeArgs args = (SomeArgs) msg.obj; inputMethod.onCreateInlineSuggestionsRequest( (InlineSuggestionsRequestInfo) args.arg1, (IInlineSuggestionsRequestCallback) args.arg2); args.recycle(); return; } Loading Loading @@ -380,9 +387,9 @@ class IInputMethodWrapper extends IInputMethod.Stub @BinderThread @Override public void hideSoftInput(int flags, ResultReceiver resultReceiver) { mCaller.executeOrSendMessage(mCaller.obtainMessageIO(DO_HIDE_SOFT_INPUT, flags, resultReceiver)); public void hideSoftInput(IBinder hideInputToken, int flags, ResultReceiver resultReceiver) { mCaller.executeOrSendMessage(mCaller.obtainMessageIOO(DO_HIDE_SOFT_INPUT, flags, hideInputToken, resultReceiver)); } @BinderThread Loading
core/java/android/inputmethodservice/InputMethodService.java +43 −1 Original line number Diff line number Diff line Loading @@ -459,6 +459,16 @@ public class InputMethodService extends AbstractInputMethodService { */ private IBinder mCurShowInputToken; /** * An opaque {@link Binder} token of window requesting {@link InputMethodImpl#hideSoftInput} * The original app window token is passed from client app window. * {@link com.android.server.inputmethod.InputMethodManagerService} creates a unique dummy * token to identify this window. * This dummy token is only valid for a single call to {@link InputMethodImpl#hideSoftInput}, * after which it is set {@code null} until next call. */ private IBinder mCurHideInputToken; final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> { onComputeInsets(mTmpInsets); if (isExtractViewShown()) { Loading Loading @@ -500,6 +510,7 @@ public class InputMethodService extends AbstractInputMethodService { public class InputMethodImpl extends AbstractInputMethodImpl { private boolean mSystemCallingShowSoftInput; private boolean mSystemCallingHideSoftInput; /** * {@inheritDoc} Loading Loading @@ -634,6 +645,21 @@ public class InputMethodService extends AbstractInputMethodService { } } /** * {@inheritDoc} * @hide */ @MainThread @Override public void hideSoftInputWithToken(int flags, ResultReceiver resultReceiver, IBinder hideInputToken) { mSystemCallingHideSoftInput = true; mCurHideInputToken = hideInputToken; hideSoftInput(flags, resultReceiver); mCurHideInputToken = null; mSystemCallingHideSoftInput = false; } /** * {@inheritDoc} */ Loading @@ -641,6 +667,12 @@ public class InputMethodService extends AbstractInputMethodService { @Override public void hideSoftInput(int flags, ResultReceiver resultReceiver) { if (DEBUG) Log.v(TAG, "hideSoftInput()"); if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.R && !mSystemCallingHideSoftInput) { Log.e(TAG, "IME shouldn't call hideSoftInput on itself." + " Use requestHideSelf(int) itself"); return; } final boolean wasVisible = mIsPreRendered ? mDecorViewVisible && mWindowVisible : isInputViewShown(); applyVisibilityInInsetsConsumerIfNecessary(false /* setVisible */); Loading Loading @@ -738,6 +770,15 @@ public class InputMethodService extends AbstractInputMethodService { public void setCurrentShowInputToken(IBinder showInputToken) { mCurShowInputToken = showInputToken; } /** * {@inheritDoc} * @hide */ @Override public void setCurrentHideInputToken(IBinder hideInputToken) { mCurHideInputToken = hideInputToken; } } // TODO(b/137800469): Add detailed docs explaining the inline suggestions process. Loading Loading @@ -2172,7 +2213,8 @@ public class InputMethodService extends AbstractInputMethodService { if (!isVisibilityAppliedUsingInsetsConsumer()) { return; } mPrivOps.applyImeVisibility(mCurShowInputToken, setVisible); mPrivOps.applyImeVisibility(setVisible ? mCurShowInputToken : mCurHideInputToken, setVisible); } private boolean isVisibilityAppliedUsingInsetsConsumer() { Loading
core/java/android/view/inputmethod/InputMethod.java +30 −0 Original line number Diff line number Diff line Loading @@ -348,6 +348,27 @@ public interface InputMethod { * {@link InputMethodManager#RESULT_UNCHANGED_HIDDEN InputMethodManager.RESULT_UNCHANGED_HIDDEN}, * {@link InputMethodManager#RESULT_SHOWN InputMethodManager.RESULT_SHOWN}, or * {@link InputMethodManager#RESULT_HIDDEN InputMethodManager.RESULT_HIDDEN}. * @param hideInputToken an opaque {@link android.os.Binder} token to identify which API call * of {@link InputMethodManager#hideSoftInputFromWindow(IBinder, int)}} is associated * with this callback. * @hide */ @MainThread public void hideSoftInputWithToken(int flags, ResultReceiver resultReceiver, IBinder hideInputToken); /** * Request that any soft input part of the input method be hidden from the user. * @param flags Provides additional information about the show request. * Currently always 0. * @param resultReceiver The client requesting the show may wish to * be told the impact of their request, which should be supplied here. * The result code should be * {@link InputMethodManager#RESULT_UNCHANGED_SHOWN InputMethodManager.RESULT_UNCHANGED_SHOWN}, * {@link InputMethodManager#RESULT_UNCHANGED_HIDDEN * InputMethodManager.RESULT_UNCHANGED_HIDDEN}, * {@link InputMethodManager#RESULT_SHOWN InputMethodManager.RESULT_SHOWN}, or * {@link InputMethodManager#RESULT_HIDDEN InputMethodManager.RESULT_HIDDEN}. */ @MainThread public void hideSoftInput(int flags, ResultReceiver resultReceiver); Loading @@ -366,4 +387,13 @@ public interface InputMethod { * @hide */ public void setCurrentShowInputToken(IBinder showInputToken); /** * Update token of the client window requesting {@link #hideSoftInput(int, ResultReceiver)} * @param hideInputToken dummy app window token for window requesting * {@link InputMethodManager#hideSoftInputFromWindow(IBinder, int)} * @hide */ public void setCurrentHideInputToken(IBinder hideInputToken); }
core/java/android/view/inputmethod/InputMethodManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -1709,7 +1709,7 @@ public final class InputMethodManager { } try { return mService.hideSoftInput(mClient, flags, resultReceiver); return mService.hideSoftInput(mClient, windowToken, flags, resultReceiver); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -1986,7 +1986,8 @@ public final class InputMethodManager { @UnsupportedAppUsage void closeCurrentInput() { try { mService.hideSoftInput(mClient, HIDE_NOT_ALWAYS, null); mService.hideSoftInput( mClient, mCurRootView.getView().getWindowToken(), HIDE_NOT_ALWAYS, null); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/com/android/internal/inputmethod/IInputMethodPrivilegedOperations.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -41,5 +41,5 @@ interface IInputMethodPrivilegedOperations { boolean shouldOfferSwitchingToNextInputMethod(); void notifyUserAction(); void reportPreRendered(in EditorInfo info); void applyImeVisibility(IBinder showInputToken, boolean setVisible); void applyImeVisibility(IBinder showOrHideInputToken, boolean setVisible); }