Deal correctly with an unset brightness adjustment.

Change-Id: I191051989bad68f31210bbc717fbabd59d4585a1
This commit is contained in:
Dianne Hackborn
2012-04-23 18:22:13 -07:00
parent f1e26a1bb3
commit 704cc2f600

View File

@@ -134,20 +134,17 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
private int getBrightness() { private int getBrightness() {
int mode = getBrightnessMode(0); int mode = getBrightnessMode(0);
float brightness = 0; float brightness = 0;
try {
if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) { if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
brightness = Settings.System.getFloat(getContext().getContentResolver(), brightness = Settings.System.getFloat(getContext().getContentResolver(),
Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ); Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0);
brightness = (brightness+1)/2; brightness = (brightness+1)/2;
} else { } else {
brightness = Settings.System.getInt(getContext().getContentResolver(), brightness = Settings.System.getInt(getContext().getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS); Settings.System.SCREEN_BRIGHTNESS, 100);
brightness = (MAXIMUM_BACKLIGHT - mScreenBrightnessDim) brightness = (MAXIMUM_BACKLIGHT - mScreenBrightnessDim)
/ (brightness - mScreenBrightnessDim); / (brightness - mScreenBrightnessDim);
} }
} catch (SettingNotFoundException snfe) {
}
return (int)(brightness*10000); return (int)(brightness*10000);
} }