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

Commit f23c3bfe authored by Felix Stern's avatar Felix Stern
Browse files

Passing Ime statsToken from InputMethodManager to InsetsController

Calls from InputMethodManager are in general redirected to InsetsController. In case of InputMethodManager#hideSoftInputFromWindow and InputMethodManager.DelegateImpl#onWindowLostFocus, we didn't pass the statsToken. Thus, the request was only tracked from InsetsController. To have the right origin, we pass the statsToken now.

Test: None, logs only
Fix: 382006185
Flag: android.view.inputmethod.refactor_insets_controller
Change-Id: I4197726ae3f4918d7fb52e2757721ddf5d2d105d
parent d8dacaf6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -946,11 +946,16 @@ public final class InputMethodManager {
                        if (state == WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) {
                            // when losing focus (e.g., by going to another window), we reset the
                            // requestedVisibleTypes of WindowInsetsController by hiding the IME
                            final var statsToken = ImeTracker.forLogging().onStart(
                                    ImeTracker.TYPE_HIDE, ImeTracker.ORIGIN_CLIENT,
                                    SoftInputShowHideReason.REASON_HIDE_WINDOW_LOST_FOCUS,
                                    false /* fromUser */);
                            if (DEBUG) {
                                Log.d(TAG, "onWindowLostFocus, hiding IME because "
                                        + "of STATE_ALWAYS_HIDDEN");
                            }
                            mCurRootView.getInsetsController().hide(WindowInsets.Type.ime());
                            mCurRootView.getInsetsController().hide(WindowInsets.Type.ime(),
                                    false /* fromIme */, statsToken);
                        }
                    }

+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import java.lang.annotation.Retention;
        SoftInputShowHideReason.CONTROL_WINDOW_INSETS_ANIMATION,
        SoftInputShowHideReason.SHOW_INPUT_TARGET_CHANGED,
        SoftInputShowHideReason.HIDE_INPUT_TARGET_CHANGED,
        SoftInputShowHideReason.REASON_HIDE_WINDOW_LOST_FOCUS,
})
public @interface SoftInputShowHideReason {
    /** Default, undefined reason. */
@@ -418,4 +419,7 @@ public @interface SoftInputShowHideReason {
     * {@link android.view.InsetsController#controlWindowInsetsAnimation}.
     */
    int CONTROL_WINDOW_INSETS_ANIMATION = ImeProtoEnums.REASON_CONTROL_WINDOW_INSETS_ANIMATION;

    /** Hide soft input when the window lost focus. */
    int REASON_HIDE_WINDOW_LOST_FOCUS = ImeProtoEnums.REASON_HIDE_WINDOW_LOST_FOCUS;
}