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

Commit 7ef50770 authored by Guliz Tuncay's avatar Guliz Tuncay Committed by Android (Google) Code Review
Browse files

Merge "Clean up TSMS#setCurrentSpellCheckerLocked."

parents 555b8176 1c94b8cc
Loading
Loading
Loading
Loading
+7 −11
Original line number Original line Diff line number Diff line
@@ -191,7 +191,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
                // 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
                // checkers.
                // checkers.
                setCurrentSpellCheckerLocked(sci.getId());
                setCurrentSpellCheckerLocked(sci);
            }
            }
        }
        }
    }
    }
@@ -230,9 +230,10 @@ 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);
                    SpellCheckerInfo availSci = findAvailSpellCheckerLocked(packageName);
                    if (sci != null) {
                    // Set the spell checker settings if different than before
                        setCurrentSpellCheckerLocked(sci.getId());
                    if (availSci != null && !availSci.getId().equals(sci.getId())) {
                        setCurrentSpellCheckerLocked(availSci);
                    }
                    }
                }
                }
            }
            }
@@ -643,16 +644,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        }
        }
    }
    }


    private void setCurrentSpellCheckerLocked(String sciId) {
    private void setCurrentSpellCheckerLocked(SpellCheckerInfo sci) {
        final String sciId = sci.getId();
        if (DBG) {
        if (DBG) {
            Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
            Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
        }
        }
        if (TextUtils.isEmpty(sciId) || !mSpellCheckerMap.containsKey(sciId)) return;
        final SpellCheckerInfo currentSci = getCurrentSpellChecker(null);
        if (currentSci != null && currentSci.getId().equals(sciId)) {
            // Do nothing if the current spell checker is same as new spell checker.
            return;
        }
        final long ident = Binder.clearCallingIdentity();
        final long ident = Binder.clearCallingIdentity();
        try {
        try {
            mSettings.putSelectedSpellChecker(sciId);
            mSettings.putSelectedSpellChecker(sciId);