Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92990f8e authored by Michael W's avatar Michael W
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
parent 787eeccc
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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;
    }