diff options
3 files changed, 21 insertions, 100 deletions
diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java index c08cd7284876..3e231d0aaa8b 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java +++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java @@ -266,43 +266,6 @@ public class InputMethodUtils { } } - private static InputMethodListBuilder getMinimumKeyboardSetWithoutSystemLocale( - final ArrayList<InputMethodInfo> imis, final Context context, - @Nullable final Locale fallbackLocale) { - // Before the system becomes ready, we pick up at least one keyboard in the following order. - // The first user (device owner) falls into this category. - // 1. checkDefaultAttribute: true, locale: fallbackLocale, checkCountry: true - // 2. checkDefaultAttribute: false, locale: fallbackLocale, checkCountry: true - // 3. checkDefaultAttribute: true, locale: fallbackLocale, checkCountry: false - // 4. checkDefaultAttribute: false, locale: fallbackLocale, checkCountry: false - // TODO: We should check isAsciiCapable instead of relying on fallbackLocale. - - final InputMethodListBuilder builder = new InputMethodListBuilder(); - builder.fillImes(imis, context, true /* checkDefaultAttribute */, fallbackLocale, - true /* checkCountry */, SUBTYPE_MODE_KEYBOARD); - if (!builder.isEmpty()) { - return builder; - } - builder.fillImes(imis, context, false /* checkDefaultAttribute */, fallbackLocale, - true /* checkCountry */, SUBTYPE_MODE_KEYBOARD); - if (!builder.isEmpty()) { - return builder; - } - builder.fillImes(imis, context, true /* checkDefaultAttribute */, fallbackLocale, - false /* checkCountry */, SUBTYPE_MODE_KEYBOARD); - if (!builder.isEmpty()) { - return builder; - } - builder.fillImes(imis, context, false /* checkDefaultAttribute */, fallbackLocale, - false /* checkCountry */, SUBTYPE_MODE_KEYBOARD); - if (!builder.isEmpty()) { - return builder; - } - Slog.w(TAG, "No software keyboard is found. imis=" + Arrays.toString(imis.toArray()) - + " fallbackLocale=" + fallbackLocale); - return builder; - } - private static InputMethodListBuilder getMinimumKeyboardSetWithSystemLocale( final ArrayList<InputMethodInfo> imis, final Context context, @Nullable final Locale systemLocale, @Nullable final Locale fallbackLocale) { @@ -353,21 +316,10 @@ public class InputMethodUtils { } public static ArrayList<InputMethodInfo> getDefaultEnabledImes(final Context context, - final boolean isSystemReady, final ArrayList<InputMethodInfo> imis) { + final ArrayList<InputMethodInfo> imis) { final Locale fallbackLocale = getFallbackLocaleForDefaultIme(imis, context); - if (!isSystemReady) { - // When the system is not ready, the system locale is not stable and reliable. Hence - // we will pick up IMEs that support software keyboard based on the fallback locale. - // Also pick up suitable IMEs regardless of the software keyboard support. - // (e.g. Voice IMEs) - return getMinimumKeyboardSetWithoutSystemLocale(imis, context, fallbackLocale) - .fillImes(imis, context, true /* checkDefaultAttribute */, fallbackLocale, - true /* checkCountry */, SUBTYPE_MODE_ANY) - .build(); - } - - // When the system is ready, we will primarily rely on the system locale, but also keep - // relying on the fallback locale as a last resort. + // We will primarily rely on the system locale, but also keep relying on the fallback locale + // as a last resort. // Also pick up suitable IMEs regardless of the software keyboard support (e.g. Voice IMEs), // then pick up suitable auxiliary IMEs when necessary (e.g. Voice IMEs with "automatic" // subtype) diff --git a/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java b/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java index 97ea88557cdc..d89dc637f5e0 100644 --- a/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java +++ b/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java @@ -81,35 +81,23 @@ public class InputMethodUtilsTest extends InstrumentationTestCase { public void testVoiceImes() throws Exception { // locale: en_US assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_EN_US, - !IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); + "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_US, - !IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme"); - assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_EN_US, - IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); - assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_US, - IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", + "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", "DummyNonDefaultAutoVoiceIme1"); // locale: en_GB assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_EN_GB, - !IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); - assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_GB, - !IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme"); - assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_EN_GB, - IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); + "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_GB, - IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", + "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", "DummyNonDefaultAutoVoiceIme1"); // locale: ja_JP assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_JA_JP, - !IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); - assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_JA_JP, - !IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme"); - assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_JA_JP, - IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); + "DummyDefaultEnKeyboardIme", "DummyDefaultAutoVoiceIme"); assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_JA_JP, - IS_SYSTEM_READY, "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", + "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", "DummyNonDefaultAutoVoiceIme1"); } @@ -117,54 +105,35 @@ public class InputMethodUtilsTest extends InstrumentationTestCase { public void testKeyboardImes() throws Exception { // locale: en_US assertDefaultEnabledImes(getSamplePreinstalledImes("en-rUS"), LOCALE_EN_US, - !IS_SYSTEM_READY, "com.android.apps.inputmethod.latin"); - assertDefaultEnabledImes(getSamplePreinstalledImes("en-rUS"), LOCALE_EN_US, - IS_SYSTEM_READY, "com.android.apps.inputmethod.latin", - "com.android.apps.inputmethod.voice"); + "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); // locale: en_GB assertDefaultEnabledImes(getSamplePreinstalledImes("en-rGB"), LOCALE_EN_GB, - !IS_SYSTEM_READY, "com.android.apps.inputmethod.latin"); - assertDefaultEnabledImes(getSamplePreinstalledImes("en-rGB"), LOCALE_EN_GB, - IS_SYSTEM_READY, "com.android.apps.inputmethod.latin", - "com.android.apps.inputmethod.voice"); + "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); // locale: en_IN assertDefaultEnabledImes(getSamplePreinstalledImes("en-rIN"), LOCALE_EN_IN, - !IS_SYSTEM_READY, "com.android.apps.inputmethod.latin"); - assertDefaultEnabledImes(getSamplePreinstalledImes("en-rIN"), LOCALE_EN_IN, - IS_SYSTEM_READY, "com.android.apps.inputmethod.hindi", + "com.android.apps.inputmethod.hindi", "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); // locale: hi assertDefaultEnabledImes(getSamplePreinstalledImes("hi"), LOCALE_HI, - !IS_SYSTEM_READY, "com.android.apps.inputmethod.latin"); - assertDefaultEnabledImes(getSamplePreinstalledImes("hi"), LOCALE_HI, - IS_SYSTEM_READY, "com.android.apps.inputmethod.hindi", - "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); + "com.android.apps.inputmethod.hindi", "com.android.apps.inputmethod.latin", + "com.android.apps.inputmethod.voice"); // locale: ja_JP assertDefaultEnabledImes(getSamplePreinstalledImes("ja-rJP"), LOCALE_JA_JP, - !IS_SYSTEM_READY, "com.android.apps.inputmethod.latin"); - assertDefaultEnabledImes(getSamplePreinstalledImes("ja-rJP"), LOCALE_JA_JP, - IS_SYSTEM_READY, "com.android.apps.inputmethod.japanese", - "com.android.apps.inputmethod.voice"); + "com.android.apps.inputmethod.japanese", "com.android.apps.inputmethod.voice"); // locale: zh_CN assertDefaultEnabledImes(getSamplePreinstalledImes("zh-rCN"), LOCALE_ZH_CN, - !IS_SYSTEM_READY, "com.android.apps.inputmethod.latin"); - assertDefaultEnabledImes(getSamplePreinstalledImes("zh-rCN"), LOCALE_ZH_CN, - IS_SYSTEM_READY, "com.android.apps.inputmethod.pinyin", - "com.android.apps.inputmethod.voice"); + "com.android.apps.inputmethod.pinyin", "com.android.apps.inputmethod.voice"); // locale: zh_TW // Note: In this case, no IME is suitable for the system locale. Hence we will pick up a // fallback IME regardless of the "default" attribute. assertDefaultEnabledImes(getSamplePreinstalledImes("zh-rTW"), LOCALE_ZH_TW, - !IS_SYSTEM_READY, "com.android.apps.inputmethod.latin"); - assertDefaultEnabledImes(getSamplePreinstalledImes("zh-rTW"), LOCALE_ZH_TW, - IS_SYSTEM_READY, "com.android.apps.inputmethod.latin", - "com.android.apps.inputmethod.voice"); + "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); } @SmallTest @@ -792,10 +761,10 @@ public class InputMethodUtilsTest extends InstrumentationTestCase { } private void assertDefaultEnabledImes(final ArrayList<InputMethodInfo> preinstalledImes, - final Locale systemLocale, final boolean isSystemReady, String... expectedImeNames) { + final Locale systemLocale, String... expectedImeNames) { final Context context = createTargetContextWithLocales(new LocaleList(systemLocale)); final String[] actualImeNames = getPackageNames( - InputMethodUtils.getDefaultEnabledImes(context, isSystemReady, preinstalledImes)); + InputMethodUtils.getDefaultEnabledImes(context, preinstalledImes)); assertEquals(expectedImeNames.length, actualImeNames.length); for (int i = 0; i < expectedImeNames.length; ++i) { assertEquals(expectedImeNames[i], actualImeNames[i]); diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index bee1f9729eea..c4666dc2eaef 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -926,7 +926,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return; } final List<InputMethodInfo> suitableImes = InputMethodUtils.getDefaultEnabledImes( - context, mSystemReady, mSettings.getEnabledInputMethodListLocked()); + context, mSettings.getEnabledInputMethodListLocked()); if (suitableImes.isEmpty()) { Slog.i(TAG, "No default found"); return; @@ -3089,7 +3089,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (resetDefaultEnabledIme) { final ArrayList<InputMethodInfo> defaultEnabledIme = - InputMethodUtils.getDefaultEnabledImes(mContext, mSystemReady, mMethodList); + InputMethodUtils.getDefaultEnabledImes(mContext, mMethodList); final int N = defaultEnabledIme.size(); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = defaultEnabledIme.get(i); |