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

Commit 218c2ab0 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

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

parents 88072ab9 c2393ac3
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -985,7 +985,7 @@ public class InputMethodUtils {
            }
            }
        }
        }


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


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


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

        final List<InputMethodInfo> suitableImes = InputMethodUtils.getDefaultEnabledImes(
        InputMethodInfo defIm = null;
                context, mSystemReady, mSettings.getEnabledInputMethodListLocked());
        for (InputMethodInfo imi : mMethodList) {
        if (suitableImes.isEmpty()) {
            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 {
            Slog.i(TAG, "No default found");
            Slog.i(TAG, "No default found");
            return;
        }
        }
        }
        final InputMethodInfo defIm = suitableImes.get(0);
        if (defIm != null) {
        Slog.i(TAG, "Default found, using " + defIm.getId());
        setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_ID, false);
        setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_ID, false);
    }
    }
    }


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