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

Commit 96196358 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by android-build-merger
Browse files

Merge "Fix bugs in logic to find a default selectd IME." into nyc-dev

am: 218c2ab0

* commit '218c2ab0':
  Fix bugs in logic to find a default selectd IME.
parents e4c83d29 218c2ab0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -985,7 +985,7 @@ public class InputMethodUtils {
            }
        }

        public List<InputMethodInfo> getEnabledInputMethodListLocked() {
        public ArrayList<InputMethodInfo> getEnabledInputMethodListLocked() {
            return createEnabledInputMethodListLocked(
                    getEnabledInputMethodsAndSubtypeListLocked());
        }
@@ -1092,7 +1092,7 @@ public class InputMethodUtils {
            return isRemoved;
        }

        private List<InputMethodInfo> createEnabledInputMethodListLocked(
        private ArrayList<InputMethodInfo> createEnabledInputMethodListLocked(
                List<Pair<String, ArrayList<String>>> imsList) {
            final ArrayList<InputMethodInfo> res = new ArrayList<>();
            for (Pair<String, ArrayList<String>> ims: imsList) {
+9 −26
Original line number Diff line number Diff line
@@ -940,36 +940,19 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

    private void resetDefaultImeLocked(Context context) {
        // Do not reset the default (current) IME when it is a 3rd-party IME
        if (mCurMethodId != null
                && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))) {
        if (mCurMethodId != null && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))) {
            return;
        }

        InputMethodInfo defIm = null;
        for (InputMethodInfo imi : mMethodList) {
            if (defIm == null && mSystemReady) {
                final Locale systemLocale = context.getResources().getConfiguration().locale;
                if (InputMethodUtils.isSystemImeThatHasSubtypeOf(imi, context,
                        true /* checkDefaultAttribute */, systemLocale, false /* checkCountry */,
                        InputMethodUtils.SUBTYPE_MODE_ANY)) {
                    defIm = imi;
                    Slog.i(TAG, "Selected default: " + imi.getId());
                }
            }
        }
        if (defIm == null && mMethodList.size() > 0) {
            defIm = InputMethodUtils.getMostApplicableDefaultIME(
                    mSettings.getEnabledInputMethodListLocked());
            if (defIm != null) {
                Slog.i(TAG, "Default found, using " + defIm.getId());
            } else {
        final List<InputMethodInfo> suitableImes = InputMethodUtils.getDefaultEnabledImes(
                context, mSystemReady, mSettings.getEnabledInputMethodListLocked());
        if (suitableImes.isEmpty()) {
            Slog.i(TAG, "No default found");
            return;
        }
        }
        if (defIm != null) {
        final InputMethodInfo defIm = suitableImes.get(0);
        Slog.i(TAG, "Default found, using " + defIm.getId());
        setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_ID, false);
    }
    }

    private void resetAllInternalStateLocked(final boolean updateOnlyWhenLocaleChanged,
            final boolean resetDefaultEnabledIme) {