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

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

Merge "Fix confusions around NOT_A_SUBTYPE_ID in IMMS" into main

parents 43f6df87 c800aa77
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -270,6 +270,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    private static final int MSG_NOTIFY_IME_UID_TO_AUDIO_SERVICE = 7000;

    private static final int NOT_A_SUBTYPE_ID = InputMethodUtils.NOT_A_SUBTYPE_ID;

    private static final int INVALID_SUBTYPE_HASHCODE =
            InputMethodSettings.INVALID_SUBTYPE_HASHCODE;

    private static final String TAG_TRY_SUPPRESSING_IME_SWITCHER = "TrySuppressingImeSwitcher";
    private static final String HANDLER_THREAD_NAME = "android.imms";
    private static final String PACKAGE_MONITOR_THREAD_NAME = "android.imms2";
@@ -5442,20 +5446,23 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                mCurrentSubtype);

        // Set Subtype here
        final int newSubtypeHashcode;
        if (imi == null || subtypeId < 0) {
            settings.putSelectedSubtype(NOT_A_SUBTYPE_ID);
            newSubtypeHashcode = INVALID_SUBTYPE_HASHCODE;
            mCurrentSubtype = null;
        } else {
            if (subtypeId < imi.getSubtypeCount()) {
                InputMethodSubtype subtype = imi.getSubtypeAt(subtypeId);
                settings.putSelectedSubtype(subtype.hashCode());
                newSubtypeHashcode = subtype.hashCode();
                mCurrentSubtype = subtype;
            } else {
                settings.putSelectedSubtype(NOT_A_SUBTYPE_ID);
                // TODO(b/347093491): Probably this should be determined from the new subtype.
                newSubtypeHashcode = INVALID_SUBTYPE_HASHCODE;
                // If the subtype is not specified, choose the most applicable one
                mCurrentSubtype = getCurrentInputMethodSubtypeLocked();
            }
        }
        settings.putSelectedSubtype(newSubtypeHashcode);
        notifyInputMethodSubtypeChangedLocked(settings.getUserId(), imi, mCurrentSubtype);

        if (!setSubtypeOnly) {
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ final class InputMethodSettings {
     * used {@code -1} here. We cannot change this value as it's already saved into secure settings.
     * </p>
     */
    private static final int INVALID_SUBTYPE_HASHCODE = -1;
    static final int INVALID_SUBTYPE_HASHCODE = -1;
    /**
     * A string code that represents "no subtype" when a subtype hashcode is used.
     *