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

Commit f1f5ed54 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Check null before passing to Integer.parseInt

Just after user data is cleared, user preference associated with
PREF_KEYBOARD_LAYOUT is always empty. In such case, we might
want to return the default value immediately, rather than
calling Integer.parseInt(null) and catching NumberFormatException
unnecessarily.

BUG: 13472379
Change-Id: I8dca9a22780d057013c032bd1f56e730dcada3ce
parent a1719522
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -273,6 +273,9 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
    public static int readKeyboardThemeIndex(final SharedPreferences prefs, final Resources res) {
        final int defaultThemeIndex = readDefaultKeyboardThemeIndex(res);
        final String themeIndexString = prefs.getString(PREF_KEYBOARD_LAYOUT, null);
        if (themeIndexString == null) {
            return defaultThemeIndex;
        }
        try {
            return Integer.parseInt(themeIndexString);
        } catch (final NumberFormatException e) {