@@ -142,6 +142,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
142142 private static final String SUBTYPE_MODE_KEYBOARD = "keyboard" ;
143143 private static final String SUBTYPE_MODE_VOICE = "voice" ;
144144 private static final String TAG_TRY_SUPPRESSING_IME_SWITCHER = "TrySuppressingImeSwitcher" ;
145+ private static final String TAG_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE =
146+ "EnabledWhenDefaultIsNotAsciiCapable" ;
147+ private static final String TAG_ASCII_CAPABLE = "AsciiCapable" ;
145148
146149 final Context mContext ;
147150 final Resources mRes ;
@@ -2163,6 +2166,15 @@ public int compare(InputMethodInfo imi1, InputMethodInfo imi2) {
21632166 }
21642167 }
21652168
2169+ if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID ) {
2170+ final InputMethodSubtype currentSubtype = getCurrentInputMethodSubtype ();
2171+ if (currentSubtype != null ) {
2172+ final InputMethodInfo currentImi = mMethodMap .get (mCurMethodId );
2173+ lastInputMethodSubtypeId =
2174+ getSubtypeIdFromHashCode (currentImi , currentSubtype .hashCode ());
2175+ }
2176+ }
2177+
21662178 final int N = imList .size ();
21672179 mIms = new InputMethodInfo [N ];
21682180 mSubtypeIds = new int [N ];
@@ -2472,7 +2484,6 @@ private static ArrayList<InputMethodSubtype> getImplicitlyApplicableSubtypesLock
24722484 final HashMap <String , InputMethodSubtype > applicableModeAndSubtypesMap =
24732485 new HashMap <String , InputMethodSubtype >();
24742486 final int N = subtypes .size ();
2475- boolean containsKeyboardSubtype = false ;
24762487 for (int i = 0 ; i < N ; ++i ) {
24772488 // scan overriding implicitly enabled subtypes.
24782489 InputMethodSubtype subtype = subtypes .get (i );
@@ -2506,15 +2517,23 @@ private static ArrayList<InputMethodSubtype> getImplicitlyApplicableSubtypesLock
25062517 if (!systemLocale .equals (locale )) continue ;
25072518 }
25082519 applicableModeAndSubtypesMap .put (mode , subtype );
2509- if (!containsKeyboardSubtype
2510- && SUBTYPE_MODE_KEYBOARD .equalsIgnoreCase (subtype .getMode ())) {
2511- containsKeyboardSubtype = true ;
2512- }
25132520 }
25142521 }
2522+ final InputMethodSubtype keyboardSubtype
2523+ = applicableModeAndSubtypesMap .get (SUBTYPE_MODE_KEYBOARD );
25152524 final ArrayList <InputMethodSubtype > applicableSubtypes = new ArrayList <InputMethodSubtype >(
25162525 applicableModeAndSubtypesMap .values ());
2517- if (!containsKeyboardSubtype ) {
2526+ if (keyboardSubtype != null && !keyboardSubtype .containsExtraValueKey (TAG_ASCII_CAPABLE )) {
2527+ for (int i = 0 ; i < N ; ++i ) {
2528+ final InputMethodSubtype subtype = subtypes .get (i );
2529+ final String mode = subtype .getMode ();
2530+ if (SUBTYPE_MODE_KEYBOARD .equals (mode ) && subtype .containsExtraValueKey (
2531+ TAG_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE )) {
2532+ applicableSubtypes .add (subtype );
2533+ }
2534+ }
2535+ }
2536+ if (keyboardSubtype == null ) {
25182537 InputMethodSubtype lastResortKeyboardSubtype = findLastResortApplicableSubtypeLocked (
25192538 res , subtypes , SUBTYPE_MODE_KEYBOARD , systemLocale , true );
25202539 if (lastResortKeyboardSubtype != null ) {
0 commit comments