LatinIME: Fix NPE in getKeyboardThemeName
* Other components like KeyboardBuilder use this method and are not
guaranteed to pass a valid themeId (e.g. because it requests one of
the removed keyboard themes)
* In those cases lookup the default keyboard with DEFAULT_THEME_ID
and use that to return the theme name
Fixes: Spellchecker not doing its' job
Fixes:
java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.android.inputmethod.keyboard.KeyboardTheme.mThemeName' on a null object reference
at com.android.inputmethod.keyboard.KeyboardTheme.getKeyboardThemeName(KeyboardTheme.java:123)
Change-Id: Ib7b7b516c7747700b4e05073b806814d9da95238
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java b/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java
index 61636d7..6ad958b 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java
@@ -119,7 +119,10 @@
}
public static String getKeyboardThemeName(final int themeId) {
- final KeyboardTheme theme = searchKeyboardThemeById(themeId, KEYBOARD_THEMES);
+ KeyboardTheme theme = searchKeyboardThemeById(themeId, KEYBOARD_THEMES);
+ if (theme == null) {
+ theme = searchKeyboardThemeById(DEFAULT_THEME_ID, KEYBOARD_THEMES);
+ }
return theme.mThemeName;
}