diff --git a/core/java/android/view/textservice/TextServicesManager.java b/core/java/android/view/textservice/TextServicesManager.java index 5dca34884ab57..89c4bcbd768ca 100644 --- a/core/java/android/view/textservice/TextServicesManager.java +++ b/core/java/android/view/textservice/TextServicesManager.java @@ -146,10 +146,11 @@ public final class TextServicesManager { /** * @hide */ - public SpellCheckerSubtype getCurrentSpellCheckerSubtype() { + public SpellCheckerSubtype getCurrentSpellCheckerSubtype( + boolean allowImplicitlySelectedSubtype) { try { // Passing null as a locale for ICS - return sService.getCurrentSpellCheckerSubtype(null); + return sService.getCurrentSpellCheckerSubtype(null, allowImplicitlySelectedSubtype); } catch (RemoteException e) { Log.e(TAG, "Error in getCurrentSpellCheckerSubtype: " + e); return null; diff --git a/core/java/com/android/internal/textservice/ITextServicesManager.aidl b/core/java/com/android/internal/textservice/ITextServicesManager.aidl index b18af02ac448b..4882a127f24bb 100644 --- a/core/java/com/android/internal/textservice/ITextServicesManager.aidl +++ b/core/java/com/android/internal/textservice/ITextServicesManager.aidl @@ -30,7 +30,8 @@ import android.view.textservice.SpellCheckerSubtype; */ interface ITextServicesManager { SpellCheckerInfo getCurrentSpellChecker(String locale); - SpellCheckerSubtype getCurrentSpellCheckerSubtype(String locale); + SpellCheckerSubtype getCurrentSpellCheckerSubtype( + String locale, boolean allowImplicitlySelectedSubtype); oneway void getSpellCheckerService(String sciId, in String locale, in ITextServicesSessionListener tsListener, in ISpellCheckerSessionListener scListener, in Bundle bundle); diff --git a/services/java/com/android/server/TextServicesManagerService.java b/services/java/com/android/server/TextServicesManagerService.java index 321274fcb6411..5eae45678531e 100644 --- a/services/java/com/android/server/TextServicesManagerService.java +++ b/services/java/com/android/server/TextServicesManagerService.java @@ -131,6 +131,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub { if (DBG) Slog.d(TAG, "Add: " + compName); try { final SpellCheckerInfo sci = new SpellCheckerInfo(context, ri); + if (sci.getSubtypeCount() <= 0) { + Slog.w(TAG, "Skipping text service " + compName + + ": it does not contain subtypes."); + continue; + } list.add(sci); map.put(sci.getId(), sci); } catch (XmlPullParserException e) { @@ -186,9 +191,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub { } } + // TODO: Respect allowImplicitlySelectedSubtype // TODO: Save SpellCheckerSubtype by supported languages. @Override - public SpellCheckerSubtype getCurrentSpellCheckerSubtype(String locale) { + public SpellCheckerSubtype getCurrentSpellCheckerSubtype( + String locale, boolean allowImplicitlySelectedSubtype) { synchronized (mSpellCheckerMap) { final String subtypeHashCodeStr = Settings.Secure.getString(mContext.getContentResolver(), @@ -207,8 +214,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub { if (DBG) { Slog.w(TAG, "Return first subtype in " + sci.getId()); } - // Return the first Subtype if there is no settings for the current subtype. - return sci.getSubtypeAt(0); + return null; } final int hashCode = Integer.valueOf(subtypeHashCodeStr); for (int i = 0; i < sci.getSubtypeCount(); ++i) { @@ -223,7 +229,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub { if (DBG) { Slog.w(TAG, "Return first subtype in " + sci.getId()); } - return sci.getSubtypeAt(0); + return null; } }