Merge change I9c242127 into eclair
* changes: PowerManagerService: Animate LCD backlight changes due to autobrightness support.
This commit is contained in:
@@ -131,6 +131,8 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
static final boolean ANIMATE_KEYBOARD_LIGHTS = false;
|
||||
|
||||
static final int ANIM_STEPS = 60/4;
|
||||
// Slower animation for autobrightness changes
|
||||
static final int AUTOBRIGHTNESS_ANIM_STEPS = 60;
|
||||
|
||||
// These magic numbers are the initial state of the LEDs at boot. Ideally
|
||||
// we should read them from the driver, but our current hardware returns 0
|
||||
@@ -224,7 +226,7 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
|
||||
// could be either static or controllable at runtime
|
||||
private static final boolean mSpew = false;
|
||||
private static final boolean mDebugLightSensor = false;
|
||||
private static final boolean mDebugLightSensor = (false || mSpew);
|
||||
|
||||
/*
|
||||
static PrintStream mLog;
|
||||
@@ -1925,27 +1927,45 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
Log.d(TAG, "keyboardValue " + keyboardValue);
|
||||
}
|
||||
|
||||
boolean startAnimation = false;
|
||||
if (mScreenBrightnessOverride < 0) {
|
||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT,
|
||||
lcdValue);
|
||||
}
|
||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS,
|
||||
buttonValue);
|
||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
||||
keyboardValue);
|
||||
|
||||
// update our animation state
|
||||
if (ANIMATE_SCREEN_LIGHTS) {
|
||||
mScreenBrightness.curValue = lcdValue;
|
||||
mScreenBrightness.animating = false;
|
||||
if (ANIMATE_SCREEN_LIGHTS) {
|
||||
if (mScreenBrightness.setTargetLocked(lcdValue,
|
||||
AUTOBRIGHTNESS_ANIM_STEPS, INITIAL_SCREEN_BRIGHTNESS,
|
||||
(int)mScreenBrightness.curValue)) {
|
||||
startAnimation = true;
|
||||
}
|
||||
} else {
|
||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT,
|
||||
lcdValue);
|
||||
}
|
||||
}
|
||||
if (ANIMATE_BUTTON_LIGHTS) {
|
||||
mButtonBrightness.curValue = buttonValue;
|
||||
mButtonBrightness.animating = false;
|
||||
if (mButtonBrightness.setTargetLocked(buttonValue,
|
||||
AUTOBRIGHTNESS_ANIM_STEPS, INITIAL_BUTTON_BRIGHTNESS,
|
||||
(int)mButtonBrightness.curValue)) {
|
||||
startAnimation = true;
|
||||
}
|
||||
} else {
|
||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS,
|
||||
buttonValue);
|
||||
}
|
||||
if (ANIMATE_KEYBOARD_LIGHTS) {
|
||||
mKeyboardBrightness.curValue = keyboardValue;
|
||||
mKeyboardBrightness.animating = false;
|
||||
if (mKeyboardBrightness.setTargetLocked(keyboardValue,
|
||||
AUTOBRIGHTNESS_ANIM_STEPS, INITIAL_BUTTON_BRIGHTNESS,
|
||||
(int)mKeyboardBrightness.curValue)) {
|
||||
startAnimation = true;
|
||||
}
|
||||
} else {
|
||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
||||
keyboardValue);
|
||||
}
|
||||
if (startAnimation) {
|
||||
if (mDebugLightSensor) {
|
||||
Log.i(TAG, "lightSensorChangedLocked scheduling light animator");
|
||||
}
|
||||
mHandler.removeCallbacks(mLightAnimator);
|
||||
mHandler.post(mLightAnimator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2041,6 +2061,7 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
if (mAutoBrightessEnabled != enabled) {
|
||||
mAutoBrightessEnabled = enabled;
|
||||
// reset computed brightness
|
||||
mLightSensorValue = -1;
|
||||
mLightSensorBrightness = -1;
|
||||
|
||||
if (mHasHardwareAutoBrightness) {
|
||||
@@ -2263,14 +2284,17 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
if (ANIMATE_SCREEN_LIGHTS) {
|
||||
mScreenBrightness.curValue = brightness;
|
||||
mScreenBrightness.animating = false;
|
||||
mScreenBrightness.targetValue = -1;
|
||||
}
|
||||
if (ANIMATE_KEYBOARD_LIGHTS) {
|
||||
mKeyboardBrightness.curValue = brightness;
|
||||
mKeyboardBrightness.animating = false;
|
||||
mKeyboardBrightness.targetValue = -1;
|
||||
}
|
||||
if (ANIMATE_BUTTON_LIGHTS) {
|
||||
mButtonBrightness.curValue = brightness;
|
||||
mButtonBrightness.animating = false;
|
||||
mButtonBrightness.targetValue = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user