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

Commit 0ed2452e authored by Luca Stefani's avatar Luca Stefani Committed by Michael Bestas
Browse files

Prevent NFE in SystemUI when parsing invalid int

* Also for custom lineage keys

Change-Id: Ie0d63e2c3af2c613bb8c9bdf6ff97637e754b7ae
parent 62016c3b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -77,7 +77,11 @@ public class ClockController implements TunerService.Tunable {
        Log.d(TAG, "onTuningChanged key=" + key + " value=" + newValue);

        if (CLOCK_POSITION.equals(key)) {
            mClockPosition = newValue == null ? CLOCK_POSITION_LEFT : Integer.valueOf(newValue);
            try {
                mClockPosition = Integer.valueOf(newValue);
            } catch (NumberFormatException ex) {
                mClockPosition = CLOCK_POSITION_LEFT;
            }
        } else {
            mBlackListed = StatusBarIconController.getIconBlacklist(newValue).contains("clock");
        }
+1 −1
Original line number Diff line number Diff line
@@ -1131,7 +1131,7 @@ public class NavigationBarView extends FrameLayout implements
    @Override
    public void onTuningChanged(String key, String newValue) {
        if (NAVIGATION_BAR_MENU_ARROW_KEYS.equals(key)) {
            mShowCursorKeys = newValue != null && Integer.parseInt(newValue) != 0;
            mShowCursorKeys = TunerService.parseIntegerSwitch(newValue, false);
            setNavigationIconHints(mNavigationIconHints);
        }
    }
+6 −2
Original line number Diff line number Diff line
@@ -587,9 +587,13 @@ public class NotificationPanelView extends PanelView implements
    @Override
    public void onTuningChanged(String key, String newValue) {
        if (STATUS_BAR_QUICK_QS_PULLDOWN.equals(key)) {
            mOneFingerQuickSettingsIntercept = newValue == null ? 1 : Integer.parseInt(newValue);
            try {
                mOneFingerQuickSettingsIntercept = Integer.parseInt(newValue);
            } catch (NumberFormatException ex) {
                mOneFingerQuickSettingsIntercept = 1;
            }
        } else if (DOUBLE_TAP_SLEEP_GESTURE.equals(key)) {
            mDoubleTapToSleepEnabled = newValue == null || Integer.parseInt(newValue) == 1;
            mDoubleTapToSleepEnabled = TunerService.parseIntegerSwitch(newValue, true);
        }
    }

+6 −4
Original line number Diff line number Diff line
@@ -4750,14 +4750,16 @@ public class StatusBar extends SystemUI implements DemoMode,
    @Override
    public void onTuningChanged(String key, String newValue) {
        if (SCREEN_BRIGHTNESS_MODE.equals(key)) {
            try {
                mAutomaticBrightness = newValue != null && Integer.parseInt(newValue)
                        == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
            } catch (NumberFormatException ex) {}
        } else if (STATUS_BAR_BRIGHTNESS_CONTROL.equals(key)) {
            mBrightnessControl = newValue != null && Integer.parseInt(newValue) == 1;
            mBrightnessControl = TunerService.parseIntegerSwitch(newValue, false);
        } else if (FORCE_SHOW_NAVBAR.equals(key) && mDisplayId == Display.DEFAULT_DISPLAY &&
                mWindowManagerService != null) {
            boolean forcedVisibility = mNeedsNavigationBar ||
                    (newValue != null && Integer.parseInt(newValue) == 1);
                    TunerService.parseIntegerSwitch(newValue, false);
            boolean hasNavbar = getNavigationBarView() != null;
            if (forcedVisibility) {
                if (!hasNavbar) {
+5 −1
Original line number Diff line number Diff line
@@ -291,7 +291,11 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
            mShowSeconds = TunerService.parseIntegerSwitch(newValue, false);
            updateShowSeconds();
        } else if (CLOCK_STYLE.equals(key)) {
            mAmPmStyle = newValue == null ? AM_PM_STYLE_GONE : Integer.valueOf(newValue);
            try {
                mAmPmStyle = Integer.valueOf(newValue);
            } catch (NumberFormatException ex) {
                mAmPmStyle = AM_PM_STYLE_GONE;
            }
            mClockFormatString = ""; // force refresh
            updateClock();
        }
Loading