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

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

Enable @StartInputReason annotation in IMMS

This is a preparation to split
com.android.internal.view.InputMethodClient.

When InputMethodClient.StartInputReason annotation was originally
introduced [1], somehow we could not use that annotation in
InputMethodManagerService (IMMS) probably because of some build system
or compiler limitation since the attribute belongs to frameworks.jar
while IMMS belongs to services.jar.

Now it seems that such a limitation no longer exists, there is no
reason to not enable @StartInputReason annotation in IMMS.

@StartInputReason is @Retention(SOURCE) anyway. Hence there should
be no behavior difference at run time.

 [1]: I74e83c8ca9d1d53e31e9c7b5bda1dec6274e59c8
      33e81798

Bug: 118040692
Test: compile
Change-Id: I6a7fef9d72bd6aafe4111abc06f8887e9a761236
parent b0c26453
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ import com.android.internal.view.IInputMethodSession;
import com.android.internal.view.IInputSessionCallback;
import com.android.internal.view.InputBindResult;
import com.android.internal.view.InputMethodClient;
import com.android.internal.view.InputMethodClient.StartInputReason;
import com.android.server.EventLogTags;
import com.android.server.LocalServices;
import com.android.server.SystemService;
@@ -694,7 +695,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        final IBinder mImeToken;
        @NonNull
        final String mImeId;
        // @InputMethodClient.StartInputReason
        @StartInputReason
        final int mStartInputReason;
        final boolean mRestarting;
        @Nullable
@@ -706,7 +707,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        final int mClientBindSequenceNumber;

        StartInputInfo(@NonNull IBinder imeToken, @NonNull String imeId,
                /* @InputMethodClient.StartInputReason */ int startInputReason, boolean restarting,
                @StartInputReason int startInputReason, boolean restarting,
                @Nullable IBinder targetWindow, @NonNull EditorInfo editorInfo,
                @SoftInputModeFlags int targetWindowSoftInputMode, int clientBindSequenceNumber) {
            mSequenceNumber = sSequenceNumber.getAndIncrement();
@@ -776,7 +777,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            String mImeTokenString;
            @NonNull
            String mImeId;
            /* @InputMethodClient.StartInputReason */
            @StartInputReason
            int mStartInputReason;
            boolean mRestarting;
            @NonNull
@@ -1861,8 +1862,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

    @GuardedBy("mMethodMap")
    @NonNull
    InputBindResult attachNewInputLocked(
            /* @InputMethodClient.StartInputReason */ final int startInputReason, boolean initial) {
    InputBindResult attachNewInputLocked(@StartInputReason int startInputReason, boolean initial) {
        if (!mBoundToMethod) {
            executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO(
                    MSG_BIND_INPUT, mCurMethod, mCurClient.binding));
@@ -1893,7 +1893,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    @NonNull
    InputBindResult startInputUncheckedLocked(@NonNull ClientState cs, IInputContext inputContext,
            @MissingMethodFlags int missingMethods, @NonNull EditorInfo attribute, int controlFlags,
            /* @InputMethodClient.StartInputReason */ final int startInputReason) {
            @StartInputReason int startInputReason) {
        // If no method is currently selected, do nothing.
        if (mCurMethodId == null) {
            return InputBindResult.NO_IME;
@@ -2739,11 +2739,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    @NonNull
    @Override
    public InputBindResult startInputOrWindowGainedFocus(
            /* @InputMethodClient.StartInputReason */ final int startInputReason,
            IInputMethodClient client, IBinder windowToken, int controlFlags,
            @SoftInputModeFlags int softInputMode, int windowFlags, @Nullable EditorInfo attribute,
            IInputContext inputContext, @MissingMethodFlags int missingMethods,
            int unverifiedTargetSdkVersion) {
            @StartInputReason int startInputReason, IInputMethodClient client, IBinder windowToken,
            int controlFlags, @SoftInputModeFlags int softInputMode, int windowFlags,
            @Nullable EditorInfo attribute, IInputContext inputContext,
            @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion) {
        if (windowToken == null) {
            Slog.e(TAG, "windowToken cannot be null.");
            return InputBindResult.NULL;
@@ -2764,11 +2763,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

    @NonNull
    private InputBindResult startInputOrWindowGainedFocusInternal(
            /* @InputMethodClient.StartInputReason */ final int startInputReason,
            IInputMethodClient client, @NonNull IBinder windowToken, int controlFlags,
            @SoftInputModeFlags int softInputMode, int windowFlags, EditorInfo attribute,
            IInputContext inputContext, @MissingMethodFlags int missingMethods,
            int unverifiedTargetSdkVersion) {
            @StartInputReason int startInputReason, IInputMethodClient client,
            @NonNull IBinder windowToken, int controlFlags, @SoftInputModeFlags int softInputMode,
            int windowFlags, EditorInfo attribute, IInputContext inputContext,
            @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion) {
        // Needs to check the validity before clearing calling identity
        final boolean calledFromValidUser = calledFromValidUser();
        InputBindResult res = null;