summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Stefani <luca.stefani.ge1@gmail.com>2019-03-15 22:14:56 +0100
committerBruno Martins <bgcngm@gmail.com>2019-11-30 01:09:52 +0100
commit7c7ad3ae1e50abf6da0b8b3984dbd1f67c485192 (patch)
treee153b9c8b3fe62a2f8ad8fcedad1f7694b220c40
parent235ba69da8b549f001aefa4d40f724ccb89e3677 (diff)
downloadandroid_frameworks_base-7c7ad3ae1e50abf6da0b8b3984dbd1f67c485192.tar.gz
android_frameworks_base-7c7ad3ae1e50abf6da0b8b3984dbd1f67c485192.tar.bz2
android_frameworks_base-7c7ad3ae1e50abf6da0b8b3984dbd1f67c485192.zip
Prevent NFE in SystemUI when parsing invalid int
* Also for custom lineage keys Change-Id: Ie0d63e2c3af2c613bb8c9bdf6ff97637e754b7ae
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ClockController.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java2
6 files changed, 24 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ClockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ClockController.java
index 41cf303d037..86231827cb9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ClockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ClockController.java
@@ -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");
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 46a98f852fb..8c51742c40b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -1114,7 +1114,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);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 890963aa0b7..ad00323e4dd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -470,9 +470,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);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 93c574b029b..6922b60c7d4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -4670,14 +4670,16 @@ public class StatusBar extends SystemUI implements DemoMode,
@Override
public void onTuningChanged(String key, String newValue) {
if (SCREEN_BRIGHTNESS_MODE.equals(key)) {
- mAutomaticBrightness = newValue != null && Integer.parseInt(newValue)
- == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
+ 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) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
index 1605cd66e5a..6dc460df6a5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
@@ -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();
}
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java b/packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java
index a526603372b..746aa38cdd9 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java
@@ -65,7 +65,7 @@ public class ClockPreference extends DropDownPreference implements TunerService.
mClockEnabled = !mBlacklist.contains(mClock);
} else if (Clock.CLOCK_SECONDS.equals(key)) {
mReceivedSeconds = true;
- mHasSeconds = newValue != null && Integer.parseInt(newValue) != 0;
+ mHasSeconds = TunerService.parseIntegerSwitch(newValue, false);
}
if (!mHasSetValue && mReceivedClock && mReceivedSeconds) {
// Because of the complicated tri-state it can end up looping and setting state back to