Skip to content
Snippets Groups Projects
Commit 8d1fd38f authored by Michael W's avatar Michael W Committed by Mohammad Hasan Keramat J
Browse files

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
Signed-off-by: default avatarMohammad Hasan Keramat J <ikeramat@protonmail.com>
parent 35793518
No related branches found
No related tags found
No related merge requests found
......@@ -119,7 +119,10 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
}
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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment