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

Commit a2c86e8a authored by Henrik Baard's avatar Henrik Baard
Browse files

revent NFE in SystemUI when parsing invalid int (2)

A user can change various tunable settings setting via adb.

If the value set is not an integer, SystemUI will end up in an exception
loop.

Test: No crash when running:
      adb exec-out settings put secure sysui_qs_move_whole_rows a
      adb exec-out settings put secure qs_show_brightness a
      adb exec-out settings put secure clock_seconds a
      adb exec-out settings put secure sysui_volume_down_silent a
      adb exec-out settings put secure sysui_volume_up_silent a
      adb exec-out settings put secure sysui_do_not_disturb a
Change-Id: If9c565cbdd44db25ba7fce381c98aa0ab735bfc4
parent e7e5a35b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -127,12 +127,12 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
    @Override
    public void onTuningChanged(String key, String newValue) {
        if (ALLOW_FANCY_ANIMATION.equals(key)) {
            mAllowFancy = newValue == null || Integer.parseInt(newValue) != 0;
            mAllowFancy = TunerService.parseIntegerSwitch(newValue, true);
            if (!mAllowFancy) {
                clearAnimationState();
            }
        } else if (MOVE_FULL_ROWS.equals(key)) {
            mFullRows = newValue == null || Integer.parseInt(newValue) != 0;
            mFullRows = TunerService.parseIntegerSwitch(newValue, true);
        } else if (QuickQSPanel.NUM_QUICK_TILES.equals(key)) {
            mNumQuickTiles = mQuickQsPanel.getNumQuickTiles(mQs.getContext());
            clearAnimationState();
+1 −1
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
    }

    private void updateViewVisibilityForTuningValue(View view, @Nullable String newValue) {
        view.setVisibility(newValue == null || Integer.parseInt(newValue) != 0 ? VISIBLE : GONE);
        view.setVisibility(TunerService.parseIntegerSwitch(newValue, true) ? VISIBLE : GONE);
    }

    public void openDetails(String subPanel) {
+1 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
    @Override
    public void onTuningChanged(String key, String newValue) {
        if (CLOCK_SECONDS.equals(key)) {
            mShowSeconds = newValue != null && Integer.parseInt(newValue) != 0;
            mShowSeconds = TunerService.parseIntegerSwitch(newValue, false);
            updateShowSeconds();
        } else {
            setClockVisibleByUser(!StatusBarIconController.getIconBlacklist(newValue)
+8 −0
Original line number Diff line number Diff line
@@ -109,4 +109,12 @@ public abstract class TunerService {
        });
        dialog.show();
    }

    public static boolean parseIntegerSwitch(String value, boolean defaultValue) {
        try {
            return value != null ? Integer.parseInt(value) != 0 : defaultValue;
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public class TunerSwitch extends SwitchPreference implements Tunable {

    @Override
    public void onTuningChanged(String key, String newValue) {
        setChecked(newValue != null ? Integer.parseInt(newValue) != 0 : mDefault);
        setChecked(TunerService.parseIntegerSwitch(newValue, mDefault));
    }

    @Override
Loading