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

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

Fix confusions around NOT_A_SUBTYPE_ID in IMMS

This is a follow up to my previous CL [1], which aimed to address
confusions around "subtypeId" in InputMethodSettings.

It turns out that there remains one more instance in IMMS. Let's fix
it in the same way.

There must be no observable behavior change as both constants use the
same magic number "-1" at this moment.

 [1]: Ic4968449ea89debc3bc9e519a724c16222851235
      e95076af

Bug: 346658341
Bug: 346662143
Bug: 347093491
Test: presubmit
Flag: EXEMPT refactor
Change-Id: I35fbf5afccc30b2dc876fb23a3eda9bdf5effc8a
parent 90da65c3
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.
     *