Merge "Move Power Manager minimum screen brightness to a framework resource"
This commit is contained in:
committed by
Android (Google) Code Review
commit
6b5a752130
@@ -426,6 +426,10 @@
|
||||
<integer-array name="config_autoBrightnessLevels">
|
||||
</integer-array>
|
||||
|
||||
|
||||
<!-- Minimum screen brightness allowed by the power manager. -->
|
||||
<integer name="config_screenBrightnessDim">20</integer>
|
||||
|
||||
<!-- Array of output values for LCD backlight corresponding to the LUX values
|
||||
in the config_autoBrightnessLevels array. This array should have size one greater
|
||||
than the size of the config_autoBrightnessLevels array.
|
||||
|
||||
@@ -235,6 +235,7 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
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 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
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 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
nominalCurrentValue = preferredBrightness;
|
||||
break;
|
||||
case SCREEN_ON_BIT:
|
||||
nominalCurrentValue = Power.BRIGHTNESS_DIM;
|
||||
nominalCurrentValue = mScreenBrightnessDim;
|
||||
break;
|
||||
case 0:
|
||||
nominalCurrentValue = Power.BRIGHTNESS_OFF;
|
||||
@@ -1899,7 +1903,7 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
// 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 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
// 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 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
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 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
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 @@ public class PowerManagerService extends IPowerManager.Stub
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user