diff options
| author | 2010-12-06 17:34:20 -0800 | |
|---|---|---|
| committer | 2010-12-06 17:37:30 -0800 | |
| commit | e1d4698ffd8dfa212a733339edf9a75d0cbf8da6 (patch) | |
| tree | 802f28554d1e8a25ec98313b30bf172376f316d0 | |
| parent | 03b758ef991a483eb9fee705aa0dacdf91a57dd1 (diff) | |
Fix Settings getFloat Methods
Don't pass null to Float.parseFloat, because that throws a NPE.
Check for null and throw SettingNotFoundException to fulfill
what the JavaDoc says.
Change-Id: Iff742fb3c15be6e02f29b9dda9197dc05a867924
| -rw-r--r-- | core/java/android/provider/Settings.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index ed71da2bbe4b..1e80da7ee251 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -977,6 +977,9 @@ public final class Settings { public static float getFloat(ContentResolver cr, String name) throws SettingNotFoundException { String v = getString(cr, name); + if (v == null) { + throw new SettingNotFoundException(name); + } try { return Float.parseFloat(v); } catch (NumberFormatException e) { @@ -1577,7 +1580,7 @@ public final class Settings { * Default screen rotation when no other policy applies. * When {@link #ACCELEROMETER_ROTATION} is zero and no on-screen Activity expresses a * preference, this rotation value will be used. Must be one of the - * {@link android.view.Surface#ROTATION_0 Surface rotation constants}. + * {@link android.view.Surface#ROTATION_0 Surface rotation constants}. * * @see Display#getRotation */ @@ -2296,6 +2299,9 @@ public final class Settings { public static float getFloat(ContentResolver cr, String name) throws SettingNotFoundException { String v = getString(cr, name); + if (v == null) { + throw new SettingNotFoundException(name); + } try { return Float.parseFloat(v); } catch (NumberFormatException e) { |