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

Commit 03903ab1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add InputMethodBindingController#getSelectedMethod()" into main

parents b6325f3a 7a1b3dca
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -194,6 +194,18 @@ final class InputMethodBindingController {
        mSelectedMethodId = selectedMethodId;
    }

    /**
     * Returns {@link InputMethodInfo} that is queried from {@link #getSelectedMethodId()}.
     *
     * @return {@link InputMethodInfo} whose IME ID is the same as {@link #getSelectedMethodId()}.
     *         {@code null} otherwise
     */
    @GuardedBy("ImfLock.class")
    @Nullable
    InputMethodInfo getSelectedMethod() {
        return InputMethodSettingsRepository.get(mUserId).getMethodMap().get(mSelectedMethodId);
    }

    /**
     * The token we have made for the currently active input method, to
     * identify it in the future.
+7 −8
Original line number Diff line number Diff line
@@ -4192,10 +4192,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

    @GuardedBy("ImfLock.class")
    private boolean switchToNextInputMethodLocked(@Nullable IBinder token, boolean onlyCurrentIme) {
        final InputMethodSettings settings = InputMethodSettingsRepository.get(mCurrentUserId);
        final int userId = mCurrentUserId;
        final var currentImi = getInputMethodBindingController(userId).getSelectedMethod();
        final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked(
                onlyCurrentIme, settings.getMethodMap().get(getSelectedMethodIdLocked()),
                mCurrentSubtype);
                onlyCurrentIme, currentImi, mCurrentSubtype);
        if (nextSubtype == null) {
            return false;
        }
@@ -4210,10 +4210,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            if (!calledWithValidTokenLocked(token)) {
                return false;
            }
            final InputMethodSettings settings = InputMethodSettingsRepository.get(mCurrentUserId);
            final int userId = mCurrentUserId;
            final var currentImi = getInputMethodBindingController(userId).getSelectedMethod();
            final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked(
                    false /* onlyCurrentIme */,
                    settings.getMethodMap().get(getSelectedMethodIdLocked()), mCurrentSubtype);
                    false /* onlyCurrentIme */, currentImi, mCurrentSubtype);
            return nextSubtype != null;
        }
    }
@@ -4648,8 +4648,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            if (mCurrentUserId != mSwitchingController.getUserId()) {
                return;
            }
            final InputMethodInfo imi = InputMethodSettingsRepository.get(mCurrentUserId)
                    .getMethodMap().get(getSelectedMethodIdLocked());
            final var imi = getInputMethodBindingController(mCurrentUserId).getSelectedMethod();
            if (imi != null) {
                mSwitchingController.onUserActionLocked(imi, mCurrentSubtype);
            }