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

Commit 499e3f76 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Extract UnbindReason from InputMethodClient

This is another step to split InputMethodClient into multiple classes.

With this CL, InputMethodClient is completely removed.

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/UnbindReason.java
Change-Id: I3b96a351413025338776f6c87cbaa8cf28c3a44f
parent 4219422b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.InputMethodDebug;
import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry;
import com.android.internal.inputmethod.StartInputReason;
import com.android.internal.inputmethod.UnbindReason;
import com.android.internal.os.SomeArgs;
import com.android.internal.view.IInputConnectionWrapper;
import com.android.internal.view.IInputContext;
@@ -69,7 +70,6 @@ import com.android.internal.view.IInputMethodClient;
import com.android.internal.view.IInputMethodManager;
import com.android.internal.view.IInputMethodSession;
import com.android.internal.view.InputBindResult;
import com.android.internal.view.InputMethodClient;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -547,7 +547,7 @@ public final class InputMethodManager {
                }
                case MSG_UNBIND: {
                    final int sequence = msg.arg1;
                    @InputMethodClient.UnbindReason
                    @UnbindReason
                    final int reason = msg.arg2;
                    if (DEBUG) {
                        Log.i(TAG, "handleMessage: MSG_UNBIND " + sequence +
@@ -695,7 +695,7 @@ public final class InputMethodManager {
        }

        @Override
        public void onUnbindMethod(int sequence, @InputMethodClient.UnbindReason int unbindReason) {
        public void onUnbindMethod(int sequence, @UnbindReason int unbindReason) {
            mH.obtainMessage(MSG_UNBIND, sequence, unbindReason).sendToTarget();
        }

+7 −10
Original line number Diff line number Diff line
@@ -19,9 +19,6 @@ package com.android.internal.inputmethod;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;

import com.android.internal.view.InputMethodClient;
import com.android.internal.view.InputMethodClient.UnbindReason;

/**
 * Provides useful methods for debugging.
 */
@@ -73,19 +70,19 @@ public final class InputMethodDebug {
     */
    public static String unbindReasonToString(@UnbindReason int reason) {
        switch (reason) {
            case InputMethodClient.UNBIND_REASON_UNSPECIFIED:
            case UnbindReason.UNBIND_REASON_UNSPECIFIED:
                return "UNSPECIFIED";
            case InputMethodClient.UNBIND_REASON_SWITCH_CLIENT:
            case UnbindReason.UNBIND_REASON_SWITCH_CLIENT:
                return "SWITCH_CLIENT";
            case InputMethodClient.UNBIND_REASON_SWITCH_IME:
            case UnbindReason.UNBIND_REASON_SWITCH_IME:
                return "SWITCH_IME";
            case InputMethodClient.UNBIND_REASON_DISCONNECT_IME:
            case UnbindReason.UNBIND_REASON_DISCONNECT_IME:
                return "DISCONNECT_IME";
            case InputMethodClient.UNBIND_REASON_NO_IME:
            case UnbindReason.UNBIND_REASON_NO_IME:
                return "NO_IME";
            case InputMethodClient.UNBIND_REASON_SWITCH_IME_FAILED:
            case UnbindReason.UNBIND_REASON_SWITCH_IME_FAILED:
                return "SWITCH_IME_FAILED";
            case InputMethodClient.UNBIND_REASON_SWITCH_USER:
            case UnbindReason.UNBIND_REASON_SWITCH_USER:
                return "SWITCH_USER";
            default:
                return "Unknown=" + reason;
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.inputmethod;

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

import android.annotation.IntDef;

import java.lang.annotation.Retention;

/**
 * Describes the reason why {@link com.android.server.inputmethod.InputMethodManagerService} is
 * 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})
public @interface UnbindReason {
    /**
     * Reason is not specified.
     */
    int UNBIND_REASON_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;
    /**
     * Before a new IME becomes active, the current IME client be unbound from the previous IME.
     */
    int UNBIND_REASON_SWITCH_IME = 2;
    /**
     * When the current IME is disconnected, the current IME client will be unbound.
     */
    int UNBIND_REASON_DISCONNECT_IME = 3;
    /**
     * When the system loses the last enabled IME, the current IME client will be unbound.
     */
    int UNBIND_REASON_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;
    /**
     * 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;
}
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.internal.view.InputBindResult;
 */
oneway interface IInputMethodClient {
    void onBindMethod(in InputBindResult res);
    // unbindReason corresponds to InputMethodClient.UnbindReason.
    void onUnbindMethod(int sequence, int unbindReason);
    void setActive(boolean active, boolean fullscreen);
    void reportFullscreenMode(boolean fullscreen);
+0 −39
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.view;

import android.annotation.IntDef;

import java.lang.annotation.Retention;

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

public final class InputMethodClient {
    public static final int UNBIND_REASON_UNSPECIFIED = 0;
    public static final int UNBIND_REASON_SWITCH_CLIENT = 1;
    public static final int UNBIND_REASON_SWITCH_IME = 2;
    public static final int UNBIND_REASON_DISCONNECT_IME = 3;
    public static final int UNBIND_REASON_NO_IME = 4;
    public static final int UNBIND_REASON_SWITCH_IME_FAILED = 5;
    public static final int UNBIND_REASON_SWITCH_USER = 6;

    @Retention(SOURCE)
    @IntDef({UNBIND_REASON_UNSPECIFIED, UNBIND_REASON_SWITCH_CLIENT, UNBIND_REASON_SWITCH_IME,
            UNBIND_REASON_DISCONNECT_IME, UNBIND_REASON_NO_IME, UNBIND_REASON_SWITCH_IME_FAILED,
            UNBIND_REASON_SWITCH_USER})
    public @interface UnbindReason {}
}
Loading