Move Power Manager minimum screen brightness to a framework resource
Bug: 5279179
Change-Id: I445e78c774ad08be6582fa8870487a5210465a08
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index bbc26d6..bb21d81 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -235,6 +235,7 @@
private boolean mPreventScreenOn;
private int mScreenBrightnessOverride = -1;
private int mButtonBrightnessOverride = -1;
+ private int mScreenBrightnessDim;
private boolean mUseSoftwareAutoBrightness;
private boolean mAutoBrightessEnabled;
private int[] mAutoBrightnessLevels;
@@ -586,6 +587,9 @@
mUnplugTurnsOnScreen = resources.getBoolean(
com.android.internal.R.bool.config_unplugTurnsOnScreen);
+ mScreenBrightnessDim = resources.getInteger(
+ com.android.internal.R.integer.config_screenBrightnessDim);
+
// read settings for auto-brightness
mUseSoftwareAutoBrightness = resources.getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
@@ -1880,7 +1884,7 @@
nominalCurrentValue = preferredBrightness;
break;
case SCREEN_ON_BIT:
- nominalCurrentValue = Power.BRIGHTNESS_DIM;
+ nominalCurrentValue = mScreenBrightnessDim;
break;
case 0:
nominalCurrentValue = Power.BRIGHTNESS_OFF;
@@ -1899,7 +1903,7 @@
// the scale is because the brightness ramp isn't linear and this biases
// it so the later parts take longer.
final float scale = 1.5f;
- float ratio = (((float)Power.BRIGHTNESS_DIM)/preferredBrightness);
+ float ratio = (((float)mScreenBrightnessDim)/preferredBrightness);
if (ratio > 1.0f) ratio = 1.0f;
if ((newState & SCREEN_ON_BIT) == 0) {
if ((oldState & SCREEN_BRIGHT_BIT) != 0) {
@@ -1926,7 +1930,7 @@
// will then count going dim as turning off.
mScreenOffTime = SystemClock.elapsedRealtime();
}
- brightness = Power.BRIGHTNESS_DIM;
+ brightness = mScreenBrightnessDim;
}
}
long identity = Binder.clearCallingIdentity();
@@ -1956,7 +1960,7 @@
setLightBrightness(offMask, Power.BRIGHTNESS_OFF);
}
if (dimMask != 0) {
- int brightness = Power.BRIGHTNESS_DIM;
+ int brightness = mScreenBrightnessDim;
if ((newState & BATTERY_LOW_BIT) != 0 &&
brightness > Power.BRIGHTNESS_LOW_BATTERY) {
brightness = Power.BRIGHTNESS_LOW_BATTERY;
@@ -2122,7 +2126,7 @@
final int brightness = Settings.System.getInt(mContext.getContentResolver(),
SCREEN_BRIGHTNESS);
// Don't let applications turn the screen all the way off
- return Math.max(brightness, Power.BRIGHTNESS_DIM);
+ return Math.max(brightness, mScreenBrightnessDim);
} catch (SettingNotFoundException snfe) {
return Power.BRIGHTNESS_ON;
}
@@ -2810,7 +2814,7 @@
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
// Don't let applications turn the screen all the way off
synchronized (mLocks) {
- brightness = Math.max(brightness, Power.BRIGHTNESS_DIM);
+ brightness = Math.max(brightness, mScreenBrightnessDim);
mLcdLight.setBrightness(brightness);
mKeyboardLight.setBrightness(mKeyboardVisible ? brightness : 0);
mButtonLight.setBrightness(brightness);