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

Commit 4219422b authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Remove redundant prefix from StartInputReason

This is another step to split InputMethodClient into multiple classes.

Now that all the integer constants for StartInputReason are defined
inside StartInputReason, "START_INPUT_REASON_" prefix is just
redundant.

This is a mechanical refactoring. There should be no user-visible
behavior change.

Bug: 118040692
Test: prebuilts/checkstyle/checkstyle.py -f \
      frameworks/base/core/java/com/android/internal/inputmethod/StartInputReason.java
Change-Id: Ic2476c3d588211e6c61180cde7df4c6b79039ede
parent c6632df9
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -542,8 +542,7 @@ public final class InputMethodManager {
                        mCurId = res.id;
                        mBindSequence = res.sequence;
                    }
                    startInputInner(StartInputReason.START_INPUT_REASON_BOUND_TO_IMMS,
                            null, 0, 0, 0);
                    startInputInner(StartInputReason.BOUND_TO_IMMS, null, 0, 0, 0);
                    return;
                }
                case MSG_UNBIND: {
@@ -569,8 +568,7 @@ public final class InputMethodManager {
                    }
                    if (startInput) {
                        startInputInner(
                                StartInputReason.START_INPUT_REASON_UNBOUND_FROM_IMMS, null, 0, 0,
                                0);
                                StartInputReason.UNBOUND_FROM_IMMS, null, 0, 0, 0);
                    }
                    return;
                }
@@ -599,9 +597,8 @@ public final class InputMethodManager {
                        // handling this message.
                        if (mServedView != null && canStartInput(mServedView)) {
                            if (checkFocusNoStartInput(mRestartOnNextWindowFocus)) {
                                final int reason = active ?
                                        StartInputReason.START_INPUT_REASON_ACTIVATED_BY_IMMS :
                                        StartInputReason.START_INPUT_REASON_DEACTIVATED_BY_IMMS;
                                final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS
                                        : StartInputReason.DEACTIVATED_BY_IMMS;
                                startInputInner(reason, null, 0, 0, 0);
                            }
                        }
@@ -1388,8 +1385,7 @@ public final class InputMethodManager {
            mServedConnecting = true;
        }

        startInputInner(StartInputReason.START_INPUT_REASON_APP_CALLED_RESTART_INPUT_API, null, 0,
                0, 0);
        startInputInner(StartInputReason.APP_CALLED_RESTART_INPUT_API, null, 0, 0, 0);
    }

    boolean startInputInner(@StartInputReason int startInputReason,
@@ -1656,7 +1652,7 @@ public final class InputMethodManager {
    @UnsupportedAppUsage
    public void checkFocus() {
        if (checkFocusNoStartInput(false)) {
            startInputInner(StartInputReason.START_INPUT_REASON_CHECK_FOCUS, null, 0, 0, 0);
            startInputInner(StartInputReason.CHECK_FOCUS, null, 0, 0, 0);
        }
    }

@@ -1746,8 +1742,8 @@ public final class InputMethodManager {
            // should be done in conjunction with telling the system service
            // about the window gaining focus, to help make the transition
            // smooth.
            if (startInputInner(StartInputReason.START_INPUT_REASON_WINDOW_FOCUS_GAIN,
                    rootView.getWindowToken(), controlFlags, softInputMode, windowFlags)) {
            if (startInputInner(StartInputReason.WINDOW_FOCUS_GAIN, rootView.getWindowToken(),
                    controlFlags, softInputMode, windowFlags)) {
                return;
            }
        }
@@ -1758,7 +1754,7 @@ public final class InputMethodManager {
            try {
                if (DEBUG) Log.v(TAG, "Reporting focus gain, without startInput");
                mService.startInputOrWindowGainedFocus(
                        StartInputReason.START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY, mClient,
                        StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY, mClient,
                        rootView.getWindowToken(), controlFlags, softInputMode, windowFlags, null,
                        null, 0 /* missingMethodFlags */,
                        rootView.getContext().getApplicationInfo().targetSdkVersion);
+10 −10
Original line number Diff line number Diff line
@@ -40,25 +40,25 @@ public final class InputMethodDebug {
     */
    public static String startInputReasonToString(@StartInputReason int reason) {
        switch (reason) {
            case StartInputReason.START_INPUT_REASON_UNSPECIFIED:
            case StartInputReason.UNSPECIFIED:
                return "UNSPECIFIED";
            case StartInputReason.START_INPUT_REASON_WINDOW_FOCUS_GAIN:
            case StartInputReason.WINDOW_FOCUS_GAIN:
                return "WINDOW_FOCUS_GAIN";
            case StartInputReason.START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY:
            case StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY:
                return "WINDOW_FOCUS_GAIN_REPORT_ONLY";
            case StartInputReason.START_INPUT_REASON_APP_CALLED_RESTART_INPUT_API:
            case StartInputReason.APP_CALLED_RESTART_INPUT_API:
                return "APP_CALLED_RESTART_INPUT_API";
            case StartInputReason.START_INPUT_REASON_CHECK_FOCUS:
            case StartInputReason.CHECK_FOCUS:
                return "CHECK_FOCUS";
            case StartInputReason.START_INPUT_REASON_BOUND_TO_IMMS:
            case StartInputReason.BOUND_TO_IMMS:
                return "BOUND_TO_IMMS";
            case StartInputReason.START_INPUT_REASON_UNBOUND_FROM_IMMS:
            case StartInputReason.UNBOUND_FROM_IMMS:
                return "UNBOUND_FROM_IMMS";
            case StartInputReason.START_INPUT_REASON_ACTIVATED_BY_IMMS:
            case StartInputReason.ACTIVATED_BY_IMMS:
                return "ACTIVATED_BY_IMMS";
            case StartInputReason.START_INPUT_REASON_DEACTIVATED_BY_IMMS:
            case StartInputReason.DEACTIVATED_BY_IMMS:
                return "DEACTIVATED_BY_IMMS";
            case StartInputReason.START_INPUT_REASON_SESSION_CREATED_BY_IME:
            case StartInputReason.SESSION_CREATED_BY_IME:
                return "SESSION_CREATED_BY_IME";
            default:
                return "Unknown=" + reason;
+21 −21
Original line number Diff line number Diff line
@@ -27,66 +27,66 @@ import java.lang.annotation.Retention;
 * {@link com.android.internal.view.IInputMethodManager#startInputOrWindowGainedFocus}.
 */
@Retention(SOURCE)
@IntDef(prefix = "START_INPUT_REASON_", value = {
        StartInputReason.START_INPUT_REASON_UNSPECIFIED,
        StartInputReason.START_INPUT_REASON_WINDOW_FOCUS_GAIN,
        StartInputReason.START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY,
        StartInputReason.START_INPUT_REASON_APP_CALLED_RESTART_INPUT_API,
        StartInputReason.START_INPUT_REASON_CHECK_FOCUS,
        StartInputReason.START_INPUT_REASON_BOUND_TO_IMMS,
        StartInputReason.START_INPUT_REASON_UNBOUND_FROM_IMMS,
        StartInputReason.START_INPUT_REASON_ACTIVATED_BY_IMMS,
        StartInputReason.START_INPUT_REASON_DEACTIVATED_BY_IMMS,
        StartInputReason.START_INPUT_REASON_SESSION_CREATED_BY_IME})
@IntDef(value = {
        StartInputReason.UNSPECIFIED,
        StartInputReason.WINDOW_FOCUS_GAIN,
        StartInputReason.WINDOW_FOCUS_GAIN_REPORT_ONLY,
        StartInputReason.APP_CALLED_RESTART_INPUT_API,
        StartInputReason.CHECK_FOCUS,
        StartInputReason.BOUND_TO_IMMS,
        StartInputReason.UNBOUND_FROM_IMMS,
        StartInputReason.ACTIVATED_BY_IMMS,
        StartInputReason.DEACTIVATED_BY_IMMS,
        StartInputReason.SESSION_CREATED_BY_IME})
public @interface StartInputReason {
    /**
     * Reason is not specified.
     */
    int START_INPUT_REASON_UNSPECIFIED = 0;
    int UNSPECIFIED = 0;
    /**
     * {@link android.view.Window} gained focus and it made the focused {@link android.view.View}
     * to (re)start a new connection.
     */
    int START_INPUT_REASON_WINDOW_FOCUS_GAIN = 1;
    int WINDOW_FOCUS_GAIN = 1;
    /**
     * {@link android.view.Window} gained focus but there is no {@link android.view.View} that is
     * eligible to have IME focus. {@link android.view.inputmethod.InputMethodManager} just reports
     * this window focus change event.
     */
    int START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY = 2;
    int WINDOW_FOCUS_GAIN_REPORT_ONLY = 2;
    /**
     * {@link android.view.inputmethod.InputMethodManager#restartInput(android.view.View)} is
     * either explicitly called by the application or indirectly called by some Framework class
     * (e.g. {@link android.widget.EditText}).
     */
    int START_INPUT_REASON_APP_CALLED_RESTART_INPUT_API = 3;
    int APP_CALLED_RESTART_INPUT_API = 3;
    /**
     * {@link android.view.View} requested a new connection because of view focus change.
     */
    int START_INPUT_REASON_CHECK_FOCUS = 4;
    int CHECK_FOCUS = 4;
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#onBindMethod}.
     */
    int START_INPUT_REASON_BOUND_TO_IMMS = 5;
    int BOUND_TO_IMMS = 5;
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#onUnbindMethod}.
     */
    int START_INPUT_REASON_UNBOUND_FROM_IMMS = 6;
    int UNBOUND_FROM_IMMS = 6;
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#setActive}.
     */
    int START_INPUT_REASON_ACTIVATED_BY_IMMS = 7;
    int ACTIVATED_BY_IMMS = 7;
    /**
     * {@link android.view.inputmethod.InputMethodManager} is responding to
     * {@link com.android.internal.view.IInputMethodClient#setActive}.
     */
    int START_INPUT_REASON_DEACTIVATED_BY_IMMS = 8;
    int DEACTIVATED_BY_IMMS = 8;
    /**
     * {@link com.android.server.inputmethod.InputMethodManagerService} is responding to
     * {@link com.android.internal.view.IInputSessionCallback#sessionCreated}.
     */
    int START_INPUT_REASON_SESSION_CREATED_BY_IME = 9;
    int SESSION_CREATED_BY_IME = 9;
}
+1 −1
Original line number Diff line number Diff line
@@ -2052,7 +2052,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    mCurClient.curSession = new SessionState(mCurClient,
                            method, session, channel);
                    InputBindResult res = attachNewInputLocked(
                            StartInputReason.START_INPUT_REASON_SESSION_CREATED_BY_IME, true);
                            StartInputReason.SESSION_CREATED_BY_IME, true);
                    if (res.method != null) {
                        executeOrSendMessage(mCurClient.client, mCaller.obtainMessageOO(
                                MSG_BIND_CLIENT, mCurClient.client, res));