OSDN Git Service

Revert "Select only preinstalled Spell Checker Services"
authorBryan Ferris <bferris@google.com>
Wed, 9 Jan 2019 23:22:20 +0000 (15:22 -0800)
committerBryan Ferris <bferris@google.com>
Thu, 10 Jan 2019 00:44:27 +0000 (00:44 +0000)
This reverts commit fa265ed97026e3b8675a2ccbf4035cad6dc1523f.

Reason for revert: The backport for b/118694079 was applied improperly.

The fix involved filtering the class members list of spell checkers into a new list before searching it. The backport filtered the list but failed to update references to the class member into references to the local variable, creating no change in observable behavior. A new version of this commit will be simultaneously uploaded, which both fixes the bad behavior and allows us to have exactly 1 CL per branch that fixes the issue.

Bug: 118694079

Change-Id: Ic38a2ca2ddede7f0929779b0f2292b7823c11e87
Merged-In: Idab3ecc246fe9344a09e6907a0ba39f8ea6506f9

services/core/java/com/android/server/TextServicesManagerService.java

index 14fe6a2..4b0d4be 100644 (file)
@@ -183,7 +183,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
         buildSpellCheckerMapLocked(mContext, mSpellCheckerList, mSpellCheckerMap, mSettings);
         SpellCheckerInfo sci = getCurrentSpellChecker(null);
         if (sci == null) {
-            sci = findAvailSystemSpellCheckerLocked(null);
+            sci = findAvailSpellCheckerLocked(null);
             if (sci != null) {
                 // 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
@@ -227,7 +227,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
                         change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE
                         // Package modified
                         || isPackageModified(packageName)) {
-                    sci = findAvailSystemSpellCheckerLocked(packageName);
+                    sci = findAvailSpellCheckerLocked(packageName);
                     if (sci != null) {
                         setCurrentSpellCheckerLocked(sci.getId());
                     }
@@ -371,16 +371,8 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
         mSpellCheckerBindGroups.clear();
     }
 
-    private SpellCheckerInfo findAvailSystemSpellCheckerLocked(String prefPackage) {
-        // 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();
+    private SpellCheckerInfo findAvailSpellCheckerLocked(String prefPackage) {
+        final int spellCheckersCount = mSpellCheckerList.size();
         if (spellCheckersCount == 0) {
             Slog.w(TAG, "no available spell checker services found");
             return null;
@@ -390,7 +382,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
                 final SpellCheckerInfo sci = mSpellCheckerList.get(i);
                 if (prefPackage.equals(sci.getPackageName())) {
                     if (DBG) {
-                        Slog.d(TAG, "findAvailSystemSpellCheckerLocked: " + sci.getPackageName());
+                        Slog.d(TAG, "findAvailSpellCheckerLocked: " + sci.getPackageName());
                     }
                     return sci;
                 }
@@ -404,7 +396,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
         final ArrayList<Locale> suitableLocales =
                 InputMethodUtils.getSuitableLocalesForSpellChecker(systemLocal);
         if (DBG) {
-            Slog.w(TAG, "findAvailSystemSpellCheckerLocked suitableLocales="
+            Slog.w(TAG, "findAvailSpellCheckerLocked suitableLocales="
                     + Arrays.toString(suitableLocales.toArray(new Locale[suitableLocales.size()])));
         }
         final int localeCount = suitableLocales.size();