Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c72efabd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Deprecating ResultsReceiver usage in InputMethodManager" into main

parents 1875f9d6 8a498d23
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -56623,7 +56623,7 @@ package android.view.inputmethod {
    method public java.util.Map<android.view.inputmethod.InputMethodInfo,java.util.List<android.view.inputmethod.InputMethodSubtype>> getShortcutInputMethodsAndSubtypes();
    method @Deprecated public void hideSoftInputFromInputMethod(android.os.IBinder, int);
    method public boolean hideSoftInputFromWindow(android.os.IBinder, int);
    method public boolean hideSoftInputFromWindow(android.os.IBinder, int, android.os.ResultReceiver);
    method @Deprecated public boolean hideSoftInputFromWindow(android.os.IBinder, int, android.os.ResultReceiver);
    method @Deprecated public void hideStatusIcon(android.os.IBinder);
    method public void invalidateInput(@NonNull android.view.View);
    method public boolean isAcceptingText();
@@ -56647,7 +56647,7 @@ package android.view.inputmethod {
    method public void showInputMethodAndSubtypeEnabler(@Nullable String);
    method public void showInputMethodPicker();
    method public boolean showSoftInput(android.view.View, int);
    method public boolean showSoftInput(android.view.View, int, android.os.ResultReceiver);
    method @Deprecated public boolean showSoftInput(android.view.View, int, android.os.ResultReceiver);
    method @Deprecated public void showSoftInputFromInputMethod(android.os.IBinder, int);
    method @Deprecated public void showStatusIcon(android.os.IBinder, String, @DrawableRes int);
    method @FlaggedApi("android.view.inputmethod.connectionless_handwriting") public void startConnectionlessStylusHandwriting(@NonNull android.view.View, @Nullable android.view.inputmethod.CursorAnchorInfo, @NonNull java.util.concurrent.Executor, @NonNull android.view.inputmethod.ConnectionlessHandwritingCallback);
+30 −0
Original line number Diff line number Diff line
@@ -2352,6 +2352,13 @@ public final class InputMethodManager {
     * {@link #RESULT_HIDDEN}.
     * @return {@code true} if a request was sent to system_server, {@code false} otherwise. Note:
     * this does not return result of the request. For result use {@param resultReceiver} instead.
     *
     * @deprecated The {@link ResultReceiver} is not a reliable way of determining whether the
     * Input Method is actually shown or hidden. If result is needed, use
     * {@link android.view.WindowInsetsController#show} instead and set a
     * {@link View.OnApplyWindowInsetsListener} and verify the provided {@link WindowInsets} for
     * the visibility of IME. If result is not needed, use {@link #showSoftInput(View, int)}
     * instead.
     */
    public boolean showSoftInput(View view, @ShowFlags int flags, ResultReceiver resultReceiver) {
        return showSoftInput(view, flags, resultReceiver, SoftInputShowHideReason.SHOW_SOFT_INPUT);
@@ -2399,6 +2406,14 @@ public final class InputMethodManager {
                                & WindowInsets.Type.ime()) == 0) {
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_CLIENT_NO_ONGOING_USER_ANIMATION);
                    if (resultReceiver != null) {
                        final boolean imeReqVisible =
                                (viewRootImpl.getInsetsController().getRequestedVisibleTypes()
                                        & WindowInsets.Type.ime()) != 0;
                        resultReceiver.send(
                                imeReqVisible ? InputMethodManager.RESULT_UNCHANGED_SHOWN
                                        : InputMethodManager.RESULT_SHOWN, null);
                    }
                    // TODO(b/322992891) handle case of SHOW_IMPLICIT
                    viewRootImpl.getInsetsController().show(WindowInsets.Type.ime(),
                            false /* fromIme */, statsToken);
@@ -2531,6 +2546,13 @@ public final class InputMethodManager {
     * {@link #RESULT_HIDDEN}.
     * @return {@code true} if a request was sent to system_server, {@code false} otherwise. Note:
     * this does not return result of the request. For result use {@param resultReceiver} instead.
     *
     * @deprecated The {@link ResultReceiver} is not a reliable way of determining whether the
     * Input Method is actually shown or hidden. If result is needed, use
     * {@link android.view.WindowInsetsController#hide} instead and set a
     * {@link View.OnApplyWindowInsetsListener} and verify the provided {@link WindowInsets} for
     * the visibility of IME. If result is not needed, use
     * {@link #hideSoftInputFromView(View, int)} instead.
     */
    public boolean hideSoftInputFromWindow(IBinder windowToken, @HideFlags int flags,
            ResultReceiver resultReceiver) {
@@ -2569,6 +2591,14 @@ public final class InputMethodManager {
                // TODO(b/322992891) handle case of HIDE_IMPLICIT_ONLY
                final var viewRootImpl = servedView.getViewRootImpl();
                if (viewRootImpl != null) {
                    if (resultReceiver != null) {
                        final boolean imeReqVisible =
                                (viewRootImpl.getInsetsController().getRequestedVisibleTypes()
                                        & WindowInsets.Type.ime()) != 0;
                        resultReceiver.send(
                                !imeReqVisible ? InputMethodManager.RESULT_UNCHANGED_HIDDEN
                                        : InputMethodManager.RESULT_HIDDEN, null);
                    }
                    viewRootImpl.getInsetsController().hide(WindowInsets.Type.ime());
                }
                return true;