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

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

Merge "Simplify IMMS#switchToInputMethodLocked()" into main

parents 342b98fc e794f3ea
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ import com.android.internal.inputmethod.StartInputReason;
import com.android.internal.inputmethod.UnbindReason;
import com.android.internal.os.TransferPipe;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.CollectionUtils;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.Preconditions;
import com.android.server.AccessibilityManagerInternal;
@@ -5700,21 +5701,15 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @GuardedBy("ImfLock.class")
    private boolean switchToInputMethodLocked(@NonNull String imeId, int subtypeId,
            @UserIdInt int userId) {
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        if (mConcurrentMultiUserModeEnabled || userId == mCurrentUserId) {
            if (!settings.getMethodMap().containsKey(imeId)
                    || !settings.getEnabledInputMethodList()
                    .contains(settings.getMethodMap().get(imeId))) {
        final var settings = InputMethodSettingsRepository.get(userId);
        final var enabledImes = settings.getEnabledInputMethodList();
        if (!CollectionUtils.any(enabledImes, imi -> imi.getId().equals(imeId))) {
            return false; // IME is not found or not enabled.
        }
        if (mConcurrentMultiUserModeEnabled || userId == mCurrentUserId) {
            setInputMethodLocked(imeId, subtypeId, userId);
            return true;
        }
        if (!settings.getMethodMap().containsKey(imeId)
                || !settings.getEnabledInputMethodList().contains(
                settings.getMethodMap().get(imeId))) {
            return false; // IME is not found or not enabled.
        }
        settings.putSelectedInputMethod(imeId);
        // For non-current user, only reset subtypeId (instead of setting the given one).
        settings.putSelectedSubtype(NOT_A_SUBTYPE_ID);