Manage button and keyboard backlights with light sensor in both manual and automatic mode.
Now the manual brightness mode only applies to the LCD backlight and button and keyboard backlights are always managed automatically. Fixes bug b/2195798 (Passion capacitive key backlights don't always come on) This change only affects the framework based auto-brightness implementation. Hardware auto-brightness is not affected. Change-Id: Ib88310d642d498591e8879c8269d630ff3f7c8af Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
@@ -487,7 +487,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
// And explicitly do the initial update of our cached settings
|
// And explicitly do the initial update of our cached settings
|
||||||
updateGservicesValues();
|
updateGservicesValues();
|
||||||
|
|
||||||
if (mUseSoftwareAutoBrightness && mAutoBrightessEnabled) {
|
if (mUseSoftwareAutoBrightness) {
|
||||||
// turn the screen on
|
// turn the screen on
|
||||||
setPowerState(SCREEN_BRIGHT);
|
setPowerState(SCREEN_BRIGHT);
|
||||||
} else {
|
} else {
|
||||||
@@ -589,7 +589,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
switch (wl.flags & LOCK_MASK)
|
switch (wl.flags & LOCK_MASK)
|
||||||
{
|
{
|
||||||
case PowerManager.FULL_WAKE_LOCK:
|
case PowerManager.FULL_WAKE_LOCK:
|
||||||
if (mAutoBrightessEnabled && mUseSoftwareAutoBrightness) {
|
if (mUseSoftwareAutoBrightness) {
|
||||||
wl.minState = SCREEN_BRIGHT;
|
wl.minState = SCREEN_BRIGHT;
|
||||||
} else {
|
} else {
|
||||||
wl.minState = (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
|
wl.minState = (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
|
||||||
@@ -1300,7 +1300,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
private int setScreenStateLocked(boolean on) {
|
private int setScreenStateLocked(boolean on) {
|
||||||
int err = Power.setScreenState(on);
|
int err = Power.setScreenState(on);
|
||||||
if (err == 0 && mUseSoftwareAutoBrightness) {
|
if (err == 0 && mUseSoftwareAutoBrightness) {
|
||||||
enableLightSensor(on && mAutoBrightessEnabled);
|
enableLightSensor(on);
|
||||||
if (!on) {
|
if (!on) {
|
||||||
// make sure button and key backlights are off too
|
// make sure button and key backlights are off too
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, 0);
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, 0);
|
||||||
@@ -1346,7 +1346,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mDoneBooting && !(mAutoBrightessEnabled && mUseSoftwareAutoBrightness)) {
|
if (!mDoneBooting && !mUseSoftwareAutoBrightness) {
|
||||||
newState |= ALL_BRIGHT;
|
newState |= ALL_BRIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1858,8 +1858,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if ((mUserActivityAllowed && !mProximitySensorActive) || force) {
|
if ((mUserActivityAllowed && !mProximitySensorActive) || force) {
|
||||||
// Only turn on button backlights if a button was pressed
|
// Only turn on button backlights if a button was pressed
|
||||||
// and auto brightness is disabled
|
// and auto brightness is disabled
|
||||||
if (eventType == BUTTON_EVENT &&
|
if (eventType == BUTTON_EVENT && !mUseSoftwareAutoBrightness) {
|
||||||
!(mAutoBrightessEnabled && mUseSoftwareAutoBrightness)) {
|
|
||||||
mUserState = (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
|
mUserState = (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
|
||||||
} else {
|
} else {
|
||||||
// don't clear button/keyboard backlights when the screen is touched.
|
// don't clear button/keyboard backlights when the screen is touched.
|
||||||
@@ -1937,7 +1936,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean startAnimation = false;
|
boolean startAnimation = false;
|
||||||
if (mScreenBrightnessOverride < 0) {
|
if (mAutoBrightessEnabled && mScreenBrightnessOverride < 0) {
|
||||||
if (ANIMATE_SCREEN_LIGHTS) {
|
if (ANIMATE_SCREEN_LIGHTS) {
|
||||||
if (mScreenBrightness.setTargetLocked(lcdValue,
|
if (mScreenBrightness.setTargetLocked(lcdValue,
|
||||||
AUTOBRIGHTNESS_ANIM_STEPS, INITIAL_SCREEN_BRIGHTNESS,
|
AUTOBRIGHTNESS_ANIM_STEPS, INITIAL_SCREEN_BRIGHTNESS,
|
||||||
@@ -2049,7 +2048,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
// will take care of turning on due to a true change to the lid
|
// will take care of turning on due to a true change to the lid
|
||||||
// switch and synchronized with the lock screen.
|
// switch and synchronized with the lock screen.
|
||||||
if ((mPowerState & SCREEN_ON_BIT) != 0) {
|
if ((mPowerState & SCREEN_ON_BIT) != 0) {
|
||||||
if (mAutoBrightessEnabled && mUseSoftwareAutoBrightness) {
|
if (mUseSoftwareAutoBrightness) {
|
||||||
// force recompute of backlight values
|
// force recompute of backlight values
|
||||||
if (mLightSensorValue >= 0) {
|
if (mLightSensorValue >= 0) {
|
||||||
int value = (int)mLightSensorValue;
|
int value = (int)mLightSensorValue;
|
||||||
@@ -2084,11 +2083,13 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if (screenIsOn()) {
|
if (screenIsOn()) {
|
||||||
setBacklightBrightness((int)mScreenBrightness.curValue);
|
setBacklightBrightness((int)mScreenBrightness.curValue);
|
||||||
}
|
}
|
||||||
} else if (mUseSoftwareAutoBrightness) {
|
} else if (mUseSoftwareAutoBrightness && screenIsOn()) {
|
||||||
// reset computed brightness
|
// force recompute of backlight values
|
||||||
mLightSensorValue = -1;
|
if (mLightSensorValue >= 0) {
|
||||||
mLightSensorBrightness = -1;
|
int value = (int)mLightSensorValue;
|
||||||
enableLightSensor(screenIsOn() && enabled);
|
mLightSensorValue = -1;
|
||||||
|
lightSensorChangedLocked(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2244,7 +2245,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
// don't bother with the light sensor if auto brightness is handled in hardware
|
// don't bother with the light sensor if auto brightness is handled in hardware
|
||||||
if (mUseSoftwareAutoBrightness) {
|
if (mUseSoftwareAutoBrightness) {
|
||||||
mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
|
mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
|
||||||
enableLightSensor(mAutoBrightessEnabled);
|
enableLightSensor(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
|
|||||||
Reference in New Issue
Block a user