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

Commit b7526456 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Remove redundant prefix from UnbindReason

This is the last step to split InputMethodClient into multiple
classes.

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

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

Fix: 118040692
Test: prebuilts/checkstyle/checkstyle.py -f \
      frameworks/base/core/java/com/android/internal/inputmethod/UnbindReason.java
Change-Id: Iafce68b614dd85392d06af8726525a18b014dba0
parent 499e3f76
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -70,19 +70,19 @@ public final class InputMethodDebug {
     */
    public static String unbindReasonToString(@UnbindReason int reason) {
        switch (reason) {
            case UnbindReason.UNBIND_REASON_UNSPECIFIED:
            case UnbindReason.UNSPECIFIED:
                return "UNSPECIFIED";
            case UnbindReason.UNBIND_REASON_SWITCH_CLIENT:
            case UnbindReason.SWITCH_CLIENT:
                return "SWITCH_CLIENT";
            case UnbindReason.UNBIND_REASON_SWITCH_IME:
            case UnbindReason.SWITCH_IME:
                return "SWITCH_IME";
            case UnbindReason.UNBIND_REASON_DISCONNECT_IME:
            case UnbindReason.DISCONNECT_IME:
                return "DISCONNECT_IME";
            case UnbindReason.UNBIND_REASON_NO_IME:
            case UnbindReason.NO_IME:
                return "NO_IME";
            case UnbindReason.UNBIND_REASON_SWITCH_IME_FAILED:
            case UnbindReason.SWITCH_IME_FAILED:
                return "SWITCH_IME_FAILED";
            case UnbindReason.UNBIND_REASON_SWITCH_USER:
            case UnbindReason.SWITCH_USER:
                return "SWITCH_USER";
            default:
                return "Unknown=" + reason;
+15 −15
Original line number Diff line number Diff line
@@ -27,43 +27,43 @@ import java.lang.annotation.Retention;
 * calling {@link com.android.internal.view.IInputMethodClient#onUnbindMethod}.
 */
@Retention(SOURCE)
@IntDef(prefix = "UNBIND_REASON_", value = {
        UnbindReason.UNBIND_REASON_UNSPECIFIED,
        UnbindReason.UNBIND_REASON_SWITCH_CLIENT,
        UnbindReason.UNBIND_REASON_SWITCH_IME,
        UnbindReason.UNBIND_REASON_DISCONNECT_IME,
        UnbindReason.UNBIND_REASON_NO_IME,
        UnbindReason.UNBIND_REASON_SWITCH_IME_FAILED,
        UnbindReason.UNBIND_REASON_SWITCH_USER})
@IntDef(value = {
        UnbindReason.UNSPECIFIED,
        UnbindReason.SWITCH_CLIENT,
        UnbindReason.SWITCH_IME,
        UnbindReason.DISCONNECT_IME,
        UnbindReason.NO_IME,
        UnbindReason.SWITCH_IME_FAILED,
        UnbindReason.SWITCH_USER})
public @interface UnbindReason {
    /**
     * Reason is not specified.
     */
    int UNBIND_REASON_UNSPECIFIED = 0;
    int UNSPECIFIED = 0;
    /**
     * When a new IME client becomes active, the previous IME client will unbound from the current
     * IME.
     */
    int UNBIND_REASON_SWITCH_CLIENT = 1;
    int SWITCH_CLIENT = 1;
    /**
     * Before a new IME becomes active, the current IME client be unbound from the previous IME.
     */
    int UNBIND_REASON_SWITCH_IME = 2;
    int SWITCH_IME = 2;
    /**
     * When the current IME is disconnected, the current IME client will be unbound.
     */
    int UNBIND_REASON_DISCONNECT_IME = 3;
    int DISCONNECT_IME = 3;
    /**
     * When the system loses the last enabled IME, the current IME client will be unbound.
     */
    int UNBIND_REASON_NO_IME = 4;
    int NO_IME = 4;
    /**
     * When the system failed to switch to another IME, the current IME client will be unbound.
     */
    int UNBIND_REASON_SWITCH_IME_FAILED = 5;
    int SWITCH_IME_FAILED = 5;
    /**
     * When a new user becomes foreground, the previous IME client will be unbound from the previous
     * user's active IME.
     */
    int UNBIND_REASON_SWITCH_USER = 6;
    int SWITCH_USER = 6;
}
+6 −6
Original line number Diff line number Diff line
@@ -1507,7 +1507,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        // TODO: Is it really possible that switchUserLocked() happens before system ready?
        if (mSystemReady) {
            hideCurrentInputLocked(0, null);
            resetCurrentMethodAndClient(UnbindReason.UNBIND_REASON_SWITCH_USER);
            resetCurrentMethodAndClient(UnbindReason.SWITCH_USER);
            buildInputMethodListLocked(initialUserSwitch);
            if (TextUtils.isEmpty(mSettings.getSelectedInputMethod())) {
                // This is the first time of the user switch and
@@ -1926,7 +1926,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            mCurClientInKeyguard = isKeyguardLocked();
            // If the client is changing, we need to switch over to the new
            // one.
            unbindCurrentClientLocked(UnbindReason.UNBIND_REASON_SWITCH_CLIENT);
            unbindCurrentClientLocked(UnbindReason.SWITCH_CLIENT);
            if (DEBUG) Slog.v(TAG, "switching to client: client="
                    + cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard);

@@ -2170,7 +2170,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                mLastBindTime = SystemClock.uptimeMillis();
                mShowRequested = mInputShown;
                mInputShown = false;
                unbindCurrentClientLocked(UnbindReason.UNBIND_REASON_DISCONNECT_IME);
                unbindCurrentClientLocked(UnbindReason.DISCONNECT_IME);
            }
        }
    }
@@ -2481,12 +2481,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id));
            } catch (IllegalArgumentException e) {
                Slog.w(TAG, "Unknown input method from prefs: " + id, e);
                resetCurrentMethodAndClient(UnbindReason.UNBIND_REASON_SWITCH_IME_FAILED);
                resetCurrentMethodAndClient(UnbindReason.SWITCH_IME_FAILED);
            }
            mShortcutInputMethodsAndSubtypes.clear();
        } else {
            // There is no longer an input method set, so stop any current one.
            resetCurrentMethodAndClient(UnbindReason.UNBIND_REASON_NO_IME);
            resetCurrentMethodAndClient(UnbindReason.NO_IME);
        }
        // Here is not the perfect place to reset the switching controller. Ideally
        // mSwitchingController and mSettings should be able to share the same state.
@@ -2564,7 +2564,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                intent.putExtra("input_method_id", id);
                mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
            }
            unbindCurrentClientLocked(UnbindReason.UNBIND_REASON_SWITCH_IME);
            unbindCurrentClientLocked(UnbindReason.SWITCH_IME);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }