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

Commit d3a01980 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Ignore onStartInput when WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR"...

Merge "Ignore onStartInput when WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR" into rvc-dev am: 70ad3311

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11863061

Change-Id: I44a6add590bdc70b99201a2c0e517d0815b8f9b5
parents 3d98d21f 70ad3311
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,9 @@ package android.view.inputmethod;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;


import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR;
import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR;

import android.annotation.DrawableRes;
import android.annotation.DrawableRes;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
@@ -622,8 +625,11 @@ public final class InputMethodManager {
                        Log.v(TAG, "Reporting focus gain, without startInput"
                        Log.v(TAG, "Reporting focus gain, without startInput"
                                + ", nextFocusIsServedView=" + nextFocusIsServedView);
                                + ", nextFocusIsServedView=" + nextFocusIsServedView);
                    }
                    }
                    final int startInputReason =
                            nextFocusIsServedView ? WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR
                                    : WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR;
                    mService.startInputOrWindowGainedFocus(
                    mService.startInputOrWindowGainedFocus(
                            StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY, mClient,
                            startInputReason, mClient,
                            focusedView.getWindowToken(), startInputFlags, softInputMode,
                            focusedView.getWindowToken(), startInputFlags, softInputMode,
                            windowFlags,
                            windowFlags,
                            nextFocusIsServedView ? mCurrentTextBoxAttribute : null,
                            nextFocusIsServedView ? mCurrentTextBoxAttribute : null,
+4 −2
Original line number Original line Diff line number Diff line
@@ -46,8 +46,10 @@ public final class InputMethodDebug {
                return "UNSPECIFIED";
                return "UNSPECIFIED";
            case StartInputReason.WINDOW_FOCUS_GAIN:
            case StartInputReason.WINDOW_FOCUS_GAIN:
                return "WINDOW_FOCUS_GAIN";
                return "WINDOW_FOCUS_GAIN";
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY:
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR:
                return "WINDOW_FOCUS_GAIN_REPORT_ONLY";
                return "WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR";
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR:
                return "WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR";
            case StartInputReason.APP_CALLED_RESTART_INPUT_API:
            case StartInputReason.APP_CALLED_RESTART_INPUT_API:
                return "APP_CALLED_RESTART_INPUT_API";
                return "APP_CALLED_RESTART_INPUT_API";
            case StartInputReason.CHECK_FOCUS:
            case StartInputReason.CHECK_FOCUS:
+18 −12
Original line number Original line Diff line number Diff line
@@ -30,7 +30,8 @@ import java.lang.annotation.Retention;
@IntDef(value = {
@IntDef(value = {
        StartInputReason.UNSPECIFIED,
        StartInputReason.UNSPECIFIED,
        StartInputReason.WINDOW_FOCUS_GAIN,
        StartInputReason.WINDOW_FOCUS_GAIN,
        StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY,
        StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR,
        StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR,
        StartInputReason.APP_CALLED_RESTART_INPUT_API,
        StartInputReason.APP_CALLED_RESTART_INPUT_API,
        StartInputReason.CHECK_FOCUS,
        StartInputReason.CHECK_FOCUS,
        StartInputReason.BOUND_TO_IMMS,
        StartInputReason.BOUND_TO_IMMS,
@@ -48,46 +49,51 @@ public @interface StartInputReason {
     * to (re)start a new connection.
     * to (re)start a new connection.
     */
     */
    int WINDOW_FOCUS_GAIN = 1;
    int WINDOW_FOCUS_GAIN = 1;
    /**
     * {@link android.view.Window} gained focus and the focused view is same as current served
     * view and its input connection remains. {@link android.view.inputmethod.InputMethodManager}
     * just reports this window focus change event to sync IME input target for system.
     */
    int WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR = 2;
    /**
    /**
     * {@link android.view.Window} gained focus but there is no {@link android.view.View} that is
     * {@link android.view.Window} gained focus but there is no {@link android.view.View} that is
     * eligible to have IME focus, or the focused view is same as current served view and its
     * eligible to have IME focus. {@link android.view.inputmethod.InputMethodManager} just reports
     * input connection remains. {@link android.view.inputmethod.InputMethodManager} just reports
     * this window focus change event for logging.
     * this window focus change event to sync IME input target for system.
     */
     */
    int WINDOW_FOCUS_GAIN_REPORT_ONLY = 2;
    int WINDOW_FOCUS_GAIN_REPORT_WITHOUT_EDITOR = 3;
    /**
    /**
     * {@link android.view.inputmethod.InputMethodManager#restartInput(android.view.View)} is
     * {@link android.view.inputmethod.InputMethodManager#restartInput(android.view.View)} is
     * either explicitly called by the application or indirectly called by some Framework class
     * either explicitly called by the application or indirectly called by some Framework class
     * (e.g. {@link android.widget.EditText}).
     * (e.g. {@link android.widget.EditText}).
     */
     */
    int APP_CALLED_RESTART_INPUT_API = 3;
    int APP_CALLED_RESTART_INPUT_API = 4;
    /**
    /**
     * {@link android.view.View} requested a new connection because of view focus change.
     * {@link android.view.View} requested a new connection because of view focus change.
     */
     */
    int CHECK_FOCUS = 4;
    int CHECK_FOCUS = 5;
    /**
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#onBindMethod}.
     * {@link com.android.internal.view.IInputMethodClient#onBindMethod}.
     */
     */
    int BOUND_TO_IMMS = 5;
    int BOUND_TO_IMMS = 6;
    /**
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#onUnbindMethod}.
     * {@link com.android.internal.view.IInputMethodClient#onUnbindMethod}.
     */
     */
    int UNBOUND_FROM_IMMS = 6;
    int UNBOUND_FROM_IMMS = 7;
    /**
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#setActive}.
     * {@link com.android.internal.view.IInputMethodClient#setActive}.
     */
     */
    int ACTIVATED_BY_IMMS = 7;
    int ACTIVATED_BY_IMMS = 8;
    /**
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#setActive}.
     * {@link com.android.internal.view.IInputMethodClient#setActive}.
     */
     */
    int DEACTIVATED_BY_IMMS = 8;
    int DEACTIVATED_BY_IMMS = 9;
    /**
    /**
     * {@link com.android.server.inputmethod.InputMethodManagerService} is responding to
     * {@link com.android.server.inputmethod.InputMethodManagerService} is responding to
     * {@link com.android.internal.view.IInputSessionCallback#sessionCreated}.
     * {@link com.android.internal.view.IInputSessionCallback#sessionCreated}.
     */
     */
    int SESSION_CREATED_BY_IME = 9;
    int SESSION_CREATED_BY_IME = 10;
}
}
+19 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.server.inputmethod;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;


import static com.android.internal.inputmethod.StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR;

import static java.lang.annotation.RetentionPolicy.SOURCE;
import static java.lang.annotation.RetentionPolicy.SOURCE;


import android.Manifest;
import android.Manifest;
@@ -710,6 +712,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     */
     */
    int mImeWindowVis;
    int mImeWindowVis;


    /**
     * Checks if the client needs to start input.
     */
    private boolean mCurClientNeedStartInput = false;

    private AlertDialog.Builder mDialogBuilder;
    private AlertDialog.Builder mDialogBuilder;
    private AlertDialog mSwitchingDialog;
    private AlertDialog mSwitchingDialog;
    private IBinder mSwitchingDialogToken = new Binder();
    private IBinder mSwitchingDialogToken = new Binder();
@@ -3425,10 +3432,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client
                Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client
                        + " attribute=" + attribute + ", token = " + windowToken);
                        + " attribute=" + attribute + ", token = " + windowToken);
            }
            }
            if (attribute != null) {
            // Needs to start input when the same window focus gain but not with the same editor,
            // or when the current client needs to start input (e.g. when focusing the same
            // window after device turned screen on).
            if (attribute != null && (startInputReason != WINDOW_FOCUS_GAIN_REPORT_WITH_SAME_EDITOR
                    || mCurClientNeedStartInput)) {
                if (mIsInteractive) {
                    mCurClientNeedStartInput = false;
                }
                return startInputUncheckedLocked(cs, inputContext, missingMethods,
                return startInputUncheckedLocked(cs, inputContext, missingMethods,
                        attribute, startInputFlags, startInputReason);
                        attribute, startInputFlags, startInputReason);
            }
            }

            return new InputBindResult(
            return new InputBindResult(
                    InputBindResult.ResultCode.SUCCESS_REPORT_WINDOW_FOCUS_ONLY,
                    InputBindResult.ResultCode.SUCCESS_REPORT_WINDOW_FOCUS_ONLY,
                    null, null, null, -1, null);
                    null, null, null, -1, null);
@@ -4381,6 +4396,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private void handleSetInteractive(final boolean interactive) {
    private void handleSetInteractive(final boolean interactive) {
        synchronized (mMethodMap) {
        synchronized (mMethodMap) {
            mIsInteractive = interactive;
            mIsInteractive = interactive;
            if (!interactive) {
                mCurClientNeedStartInput = true;
            }
            updateSystemUiLocked(interactive ? mImeWindowVis : 0, mBackDisposition);
            updateSystemUiLocked(interactive ? mImeWindowVis : 0, mBackDisposition);


            // Inform the current client of the change in active status
            // Inform the current client of the change in active status