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

Commit 9606c0e9 authored by Guliz Tuncay's avatar Guliz Tuncay Committed by android-build-merger
Browse files

Merge "Update Settings properly when no Spell Checker is available." into oc-mr1-dev

am: 406d5dfb

Change-Id: Ie4eb7ae96307ac8e746f2b24b3e7a926526e1be5
parents 31ef7f3a 406d5dfb
Loading
Loading
Loading
Loading
+28 −28
Original line number Diff line number Diff line
@@ -187,14 +187,12 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        SpellCheckerInfo sci = getCurrentSpellChecker(null);
        if (sci == null) {
            sci = findAvailSystemSpellCheckerLocked(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 system spell checkers
            // available. In this case, "sci" is the first one in the available spell
            // checkers.
            setCurrentSpellCheckerLocked(sci);
        }
    }
    }

    void updateCurrentProfileIds() {
        mSettings.setCurrentProfileIds(
@@ -221,9 +219,17 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
                SpellCheckerInfo sci = getCurrentSpellChecker(null);
                buildSpellCheckerMapLocked(
                        mContext, mSpellCheckerList, mSpellCheckerMap, mSettings);
                // If no spell checker is enabled, just return. The user should explicitly
                // If spell checker is disabled, just return. The user should explicitly
                // enable the spell checker.
                if (sci == null) return;
                if (!isSpellCheckerEnabledLocked()) return;

                if (sci == null) {
                    sci = findAvailSystemSpellCheckerLocked(null);
                    // Set the current spell checker if there is one or more system spell checkers
                    // available. In this case, "sci" is the first one in the available spell
                    // checkers.
                    setCurrentSpellCheckerLocked(sci);
                } else {
                    final String packageName = sci.getPackageName();
                    final int change = isPackageDisappearing(packageName);
                    if (// Package disappearing
@@ -239,6 +245,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
                }
            }
        }
    }

    private final class TextServicesBroadcastReceiver extends BroadcastReceiver {
        @Override
@@ -652,15 +659,14 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        }
    }

    private void setCurrentSpellCheckerLocked(SpellCheckerInfo sci) {
        final String sciId = sci.getId();
    private void setCurrentSpellCheckerLocked(@Nullable SpellCheckerInfo sci) {
        final String sciId = (sci != null) ? sci.getId() : "";
        if (DBG) {
            Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
        }
        final long ident = Binder.clearCallingIdentity();
        try {
            mSettings.putSelectedSpellChecker(sciId);
            setCurrentSpellCheckerSubtypeLocked(0);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
@@ -1106,14 +1112,8 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        }

        public void putSelectedSpellChecker(@Nullable String sciId) {
            if (TextUtils.isEmpty(sciId)) {
                // OK to coalesce to null, since getSelectedSpellChecker() can take care of the
                // empty data scenario.
                putString(Settings.Secure.SELECTED_SPELL_CHECKER, null);
            } else {
            putString(Settings.Secure.SELECTED_SPELL_CHECKER, sciId);
        }
        }

        public void putSelectedSpellCheckerSubtype(int hashCode) {
            putInt(Settings.Secure.SELECTED_SPELL_CHECKER_SUBTYPE, hashCode);