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

Commit 276e18c1 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role)
Browse files

[automerger] Select only preinstalled Spell Checker Services am: ed5973b8...

[automerger] Select only preinstalled Spell Checker Services am: ed5973b8 am: 5ab7f995 am: d71a5db5

Change-Id: I9e0504f59437cc8fd72e96630a6fb753a4cbb423
parents 1684713f d71a5db5
Loading
Loading
Loading
Loading
+17 −9
Original line number Original line Diff line number Diff line
@@ -183,7 +183,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        buildSpellCheckerMapLocked(mContext, mSpellCheckerList, mSpellCheckerMap, mSettings);
        buildSpellCheckerMapLocked(mContext, mSpellCheckerList, mSpellCheckerMap, mSettings);
        SpellCheckerInfo sci = getCurrentSpellChecker(null);
        SpellCheckerInfo sci = getCurrentSpellChecker(null);
        if (sci == null) {
        if (sci == null) {
            sci = findAvailSpellCheckerLocked(null);
            sci = findAvailSystemSpellCheckerLocked(null);
            if (sci != null) {
            if (sci != null) {
                // Set the current spell checker if there is one or more spell checkers
                // Set the current spell checker if there is one or more spell checkers
                // available. In this case, "sci" is the first one in the available spell
                // available. In this case, "sci" is the first one in the available spell
@@ -227,7 +227,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
                        change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE
                        change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE
                        // Package modified
                        // Package modified
                        || isPackageModified(packageName)) {
                        || isPackageModified(packageName)) {
                    sci = findAvailSpellCheckerLocked(packageName);
                    sci = findAvailSystemSpellCheckerLocked(packageName);
                    if (sci != null) {
                    if (sci != null) {
                        setCurrentSpellCheckerLocked(sci.getId());
                        setCurrentSpellCheckerLocked(sci.getId());
                    }
                    }
@@ -371,18 +371,26 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        mSpellCheckerBindGroups.clear();
        mSpellCheckerBindGroups.clear();
    }
    }


    private SpellCheckerInfo findAvailSpellCheckerLocked(String prefPackage) {
    private SpellCheckerInfo findAvailSystemSpellCheckerLocked(String prefPackage) {
        final int spellCheckersCount = mSpellCheckerList.size();
        // Filter the spell checker list to remove spell checker services that are not pre-installed
        ArrayList<SpellCheckerInfo> spellCheckerList = new ArrayList<>();
        for (SpellCheckerInfo sci : mSpellCheckerList) {
            if ((sci.getServiceInfo().applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                spellCheckerList.add(sci);
            }
        }

        final int spellCheckersCount = spellCheckerList.size();
        if (spellCheckersCount == 0) {
        if (spellCheckersCount == 0) {
            Slog.w(TAG, "no available spell checker services found");
            Slog.w(TAG, "no available spell checker services found");
            return null;
            return null;
        }
        }
        if (prefPackage != null) {
        if (prefPackage != null) {
            for (int i = 0; i < spellCheckersCount; ++i) {
            for (int i = 0; i < spellCheckersCount; ++i) {
                final SpellCheckerInfo sci = mSpellCheckerList.get(i);
                final SpellCheckerInfo sci = spellCheckerList.get(i);
                if (prefPackage.equals(sci.getPackageName())) {
                if (prefPackage.equals(sci.getPackageName())) {
                    if (DBG) {
                    if (DBG) {
                        Slog.d(TAG, "findAvailSpellCheckerLocked: " + sci.getPackageName());
                        Slog.d(TAG, "findAvailSystemSpellCheckerLocked: " + sci.getPackageName());
                    }
                    }
                    return sci;
                    return sci;
                }
                }
@@ -396,7 +404,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        final ArrayList<Locale> suitableLocales =
        final ArrayList<Locale> suitableLocales =
                InputMethodUtils.getSuitableLocalesForSpellChecker(systemLocal);
                InputMethodUtils.getSuitableLocalesForSpellChecker(systemLocal);
        if (DBG) {
        if (DBG) {
            Slog.w(TAG, "findAvailSpellCheckerLocked suitableLocales="
            Slog.w(TAG, "findAvailSystemSpellCheckerLocked suitableLocales="
                    + Arrays.toString(suitableLocales.toArray(new Locale[suitableLocales.size()])));
                    + Arrays.toString(suitableLocales.toArray(new Locale[suitableLocales.size()])));
        }
        }
        final int localeCount = suitableLocales.size();
        final int localeCount = suitableLocales.size();
@@ -404,7 +412,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
            final Locale locale = suitableLocales.get(localeIndex);
            final Locale locale = suitableLocales.get(localeIndex);
            for (int spellCheckersIndex = 0; spellCheckersIndex < spellCheckersCount;
            for (int spellCheckersIndex = 0; spellCheckersIndex < spellCheckersCount;
                    ++spellCheckersIndex) {
                    ++spellCheckersIndex) {
                final SpellCheckerInfo info = mSpellCheckerList.get(spellCheckersIndex);
                final SpellCheckerInfo info = spellCheckerList.get(spellCheckersIndex);
                final int subtypeCount = info.getSubtypeCount();
                final int subtypeCount = info.getSubtypeCount();
                for (int subtypeIndex = 0; subtypeIndex < subtypeCount; ++subtypeIndex) {
                for (int subtypeIndex = 0; subtypeIndex < subtypeCount; ++subtypeIndex) {
                    final SpellCheckerSubtype subtype = info.getSubtypeAt(subtypeIndex);
                    final SpellCheckerSubtype subtype = info.getSubtypeAt(subtypeIndex);
@@ -423,7 +431,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        if (spellCheckersCount > 1) {
        if (spellCheckersCount > 1) {
            Slog.w(TAG, "more than one spell checker service found, picking first");
            Slog.w(TAG, "more than one spell checker service found, picking first");
        }
        }
        return mSpellCheckerList.get(0);
        return spellCheckerList.get(0);
    }
    }


    // TODO: Save SpellCheckerService by supported languages. Currently only one spell
    // TODO: Save SpellCheckerService by supported languages. Currently only one spell