Merge commit 'f634f4922894cc23a9b2298a0c971ffac763c132' into eclair-mr2-plus-aosp * commit 'f634f4922894cc23a9b2298a0c971ffac763c132': 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 boolean ANIMATE_KEYBOARD_LIGHTS = false;
|
||||||
|
|
||||||
static final int ANIM_STEPS = 60/4;
|
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
|
// 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
|
// 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
|
// could be either static or controllable at runtime
|
||||||
private static final boolean mSpew = false;
|
private static final boolean mSpew = false;
|
||||||
private static final boolean mDebugLightSensor = false;
|
private static final boolean mDebugLightSensor = (false || mSpew);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static PrintStream mLog;
|
static PrintStream mLog;
|
||||||
@@ -1925,27 +1927,45 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
Log.d(TAG, "keyboardValue " + keyboardValue);
|
Log.d(TAG, "keyboardValue " + keyboardValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean startAnimation = false;
|
||||||
if (mScreenBrightnessOverride < 0) {
|
if (mScreenBrightnessOverride < 0) {
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT,
|
if (ANIMATE_SCREEN_LIGHTS) {
|
||||||
lcdValue);
|
if (mScreenBrightness.setTargetLocked(lcdValue,
|
||||||
}
|
AUTOBRIGHTNESS_ANIM_STEPS, INITIAL_SCREEN_BRIGHTNESS,
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS,
|
(int)mScreenBrightness.curValue)) {
|
||||||
buttonValue);
|
startAnimation = true;
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
}
|
||||||
keyboardValue);
|
} else {
|
||||||
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT,
|
||||||
// update our animation state
|
lcdValue);
|
||||||
if (ANIMATE_SCREEN_LIGHTS) {
|
}
|
||||||
mScreenBrightness.curValue = lcdValue;
|
|
||||||
mScreenBrightness.animating = false;
|
|
||||||
}
|
}
|
||||||
if (ANIMATE_BUTTON_LIGHTS) {
|
if (ANIMATE_BUTTON_LIGHTS) {
|
||||||
mButtonBrightness.curValue = buttonValue;
|
if (mButtonBrightness.setTargetLocked(buttonValue,
|
||||||
mButtonBrightness.animating = false;
|
AUTOBRIGHTNESS_ANIM_STEPS, INITIAL_BUTTON_BRIGHTNESS,
|
||||||
|
(int)mButtonBrightness.curValue)) {
|
||||||
|
startAnimation = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS,
|
||||||
|
buttonValue);
|
||||||
}
|
}
|
||||||
if (ANIMATE_KEYBOARD_LIGHTS) {
|
if (ANIMATE_KEYBOARD_LIGHTS) {
|
||||||
mKeyboardBrightness.curValue = keyboardValue;
|
if (mKeyboardBrightness.setTargetLocked(keyboardValue,
|
||||||
mKeyboardBrightness.animating = false;
|
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) {
|
if (mAutoBrightessEnabled != enabled) {
|
||||||
mAutoBrightessEnabled = enabled;
|
mAutoBrightessEnabled = enabled;
|
||||||
// reset computed brightness
|
// reset computed brightness
|
||||||
|
mLightSensorValue = -1;
|
||||||
mLightSensorBrightness = -1;
|
mLightSensorBrightness = -1;
|
||||||
|
|
||||||
if (mHasHardwareAutoBrightness) {
|
if (mHasHardwareAutoBrightness) {
|
||||||
@@ -2263,14 +2284,17 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if (ANIMATE_SCREEN_LIGHTS) {
|
if (ANIMATE_SCREEN_LIGHTS) {
|
||||||
mScreenBrightness.curValue = brightness;
|
mScreenBrightness.curValue = brightness;
|
||||||
mScreenBrightness.animating = false;
|
mScreenBrightness.animating = false;
|
||||||
|
mScreenBrightness.targetValue = -1;
|
||||||
}
|
}
|
||||||
if (ANIMATE_KEYBOARD_LIGHTS) {
|
if (ANIMATE_KEYBOARD_LIGHTS) {
|
||||||
mKeyboardBrightness.curValue = brightness;
|
mKeyboardBrightness.curValue = brightness;
|
||||||
mKeyboardBrightness.animating = false;
|
mKeyboardBrightness.animating = false;
|
||||||
|
mKeyboardBrightness.targetValue = -1;
|
||||||
}
|
}
|
||||||
if (ANIMATE_BUTTON_LIGHTS) {
|
if (ANIMATE_BUTTON_LIGHTS) {
|
||||||
mButtonBrightness.curValue = brightness;
|
mButtonBrightness.curValue = brightness;
|
||||||
mButtonBrightness.animating = false;
|
mButtonBrightness.animating = false;
|
||||||
|
mButtonBrightness.targetValue = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user