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

Commit 7cc3356c authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Simplify IMMS#startInputOrWindowGainedFocusInternal() part 2/5

This is a series of CLs to reduce the average indentation level of
InputMethodManagerService#startInputOrWindowGainedFocusInternal().

With this CL, the IMMS lock is aquired by the caller side, which
reduces the indentation level of startInputOrWindowGainedFocus() by
one level.

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

Bug: 34886274
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: I4ccc56f376551a313fe363d48607021ed0a7933c
parent 4391c204
Loading
Loading
Loading
Loading
+190 −189
Original line number Diff line number Diff line
@@ -2772,9 +2772,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        } else {
            userId = callingUserId;
        }
        final InputBindResult result = startInputOrWindowGainedFocusInternal(startInputReason,
                client, windowToken, startInputFlags, softInputMode, windowFlags, attribute,
        final InputBindResult result;
        synchronized (mMethodMap) {
            result = startInputOrWindowGainedFocusInternalLocked(startInputReason, client,
                    windowToken, startInputFlags, softInputMode, windowFlags, attribute,
                    inputContext, missingMethods, unverifiedTargetSdkVersion, userId);
        }
        if (result == null) {
            // This must never happen, but just in case.
            Slog.wtf(TAG, "InputBindResult is @NonNull. startInputReason="
@@ -2787,19 +2790,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    }

    @NonNull
    private InputBindResult startInputOrWindowGainedFocusInternal(
    private InputBindResult startInputOrWindowGainedFocusInternalLocked(
            @StartInputReason int startInputReason, IInputMethodClient client,
            @NonNull IBinder windowToken, @StartInputFlags int startInputFlags,
            @SoftInputModeFlags int softInputMode, int windowFlags, EditorInfo attribute,
            IInputContext inputContext, @MissingMethodFlags int missingMethods,
            int unverifiedTargetSdkVersion, @UserIdInt int userId) {
        synchronized (mMethodMap) {
        InputBindResult res = null;
        final int windowDisplayId =
                mWindowManagerInternal.getDisplayIdForWindow(windowToken);
        final long ident = Binder.clearCallingIdentity();
        try {
                if (DEBUG) Slog.v(TAG, "startInputOrWindowGainedFocusInternal: reason="
            if (DEBUG) Slog.v(TAG, "startInputOrWindowGainedFocusInternalLocked: reason="
                    + InputMethodDebug.startInputReasonToString(startInputReason)
                    + " client=" + client.asBinder()
                    + " inputContext=" + inputContext
@@ -3006,7 +3008,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
        return res;
    }
    }

    private boolean canShowInputMethodPickerLocked(IInputMethodClient client) {
        // TODO(yukawa): multi-display support.