am e93f49b7: am cc9a63db: Add support for specifying the current LCD brightness mode to the backlight driver.
Merge commit 'e93f49b7ff34b1f8c689b6a3ed85ef92b64d094a' into eclair-mr2-plus-aosp * commit 'e93f49b7ff34b1f8c689b6a3ed85ef92b64d094a': Add support for specifying the current LCD brightness mode to the backlight driver.
This commit is contained in:
@@ -54,6 +54,16 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
static final int LIGHT_FLASH_TIMED = 1;
|
static final int LIGHT_FLASH_TIMED = 1;
|
||||||
static final int LIGHT_FLASH_HARDWARE = 2;
|
static final int LIGHT_FLASH_HARDWARE = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Light brightness is managed by a user setting.
|
||||||
|
*/
|
||||||
|
static final int BRIGHTNESS_MODE_USER = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Light brightness is managed by a light sensor.
|
||||||
|
*/
|
||||||
|
static final int BRIGHTNESS_MODE_SENSOR = 1;
|
||||||
|
|
||||||
private final LinkedList<Vibration> mVibrations;
|
private final LinkedList<Vibration> mVibrations;
|
||||||
private Vibration mCurrentVibration;
|
private Vibration mCurrentVibration;
|
||||||
|
|
||||||
@@ -266,21 +276,21 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setLightOff_UNCHECKED(int light) {
|
void setLightOff_UNCHECKED(int light) {
|
||||||
setLight_native(mNativePointer, light, 0, LIGHT_FLASH_NONE, 0, 0);
|
setLight_native(mNativePointer, light, 0, LIGHT_FLASH_NONE, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLightBrightness_UNCHECKED(int light, int brightness) {
|
void setLightBrightness_UNCHECKED(int light, int brightness, int brightnessMode) {
|
||||||
int b = brightness & 0x000000ff;
|
int b = brightness & 0x000000ff;
|
||||||
b = 0xff000000 | (b << 16) | (b << 8) | b;
|
b = 0xff000000 | (b << 16) | (b << 8) | b;
|
||||||
setLight_native(mNativePointer, light, b, LIGHT_FLASH_NONE, 0, 0);
|
setLight_native(mNativePointer, light, b, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLightColor_UNCHECKED(int light, int color) {
|
void setLightColor_UNCHECKED(int light, int color) {
|
||||||
setLight_native(mNativePointer, light, color, LIGHT_FLASH_NONE, 0, 0);
|
setLight_native(mNativePointer, light, color, LIGHT_FLASH_NONE, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLightFlashing_UNCHECKED(int light, int color, int mode, int onMS, int offMS) {
|
void setLightFlashing_UNCHECKED(int light, int color, int mode, int onMS, int offMS) {
|
||||||
setLight_native(mNativePointer, light, color, mode, onMS, offMS);
|
setLight_native(mNativePointer, light, color, mode, onMS, offMS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttentionLight(boolean on, int color) {
|
public void setAttentionLight(boolean on, int color) {
|
||||||
@@ -289,7 +299,7 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
mAttentionLightOn = on;
|
mAttentionLightOn = on;
|
||||||
mPulsing = false;
|
mPulsing = false;
|
||||||
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, color,
|
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, color,
|
||||||
LIGHT_FLASH_HARDWARE, on ? 3 : 0, 0);
|
LIGHT_FLASH_HARDWARE, on ? 3 : 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +314,7 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
if (!mAttentionLightOn && !mPulsing) {
|
if (!mAttentionLightOn && !mPulsing) {
|
||||||
mPulsing = true;
|
mPulsing = true;
|
||||||
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, 0x00ffffff,
|
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, 0x00ffffff,
|
||||||
LIGHT_FLASH_HARDWARE, 7, 0);
|
LIGHT_FLASH_HARDWARE, 7, 0, 0);
|
||||||
mH.sendMessageDelayed(Message.obtain(mH, 1), 3000);
|
mH.sendMessageDelayed(Message.obtain(mH, 1), 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,7 +331,7 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
mPulsing = false;
|
mPulsing = false;
|
||||||
setLight_native(mNativePointer, LIGHT_ID_ATTENTION,
|
setLight_native(mNativePointer, LIGHT_ID_ATTENTION,
|
||||||
mAttentionLightOn ? 0xffffffff : 0,
|
mAttentionLightOn ? 0xffffffff : 0,
|
||||||
LIGHT_FLASH_NONE, 0, 0);
|
LIGHT_FLASH_NONE, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,7 +494,7 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
private static native void finalize_native(int ptr);
|
private static native void finalize_native(int ptr);
|
||||||
|
|
||||||
private static native void setLight_native(int ptr, int light, int color, int mode,
|
private static native void setLight_native(int ptr, int light, int color, int mode,
|
||||||
int onMS, int offMS);
|
int onMS, int offMS, int brightnessMode);
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final PowerManager.WakeLock mWakeLock;
|
private final PowerManager.WakeLock mWakeLock;
|
||||||
|
|||||||
@@ -1324,8 +1324,13 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
enableLightSensor(on);
|
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);
|
int brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, 0);
|
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
||||||
|
: HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, 0,
|
||||||
|
brightnessMode);
|
||||||
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, 0,
|
||||||
|
brightnessMode);
|
||||||
// clear current value so we will update based on the new conditions
|
// clear current value so we will update based on the new conditions
|
||||||
// when the sensor is reenabled.
|
// when the sensor is reenabled.
|
||||||
mLightSensorValue = -1;
|
mLightSensorValue = -1;
|
||||||
@@ -1680,14 +1685,23 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setLightBrightness(int mask, int value) {
|
private void setLightBrightness(int mask, int value) {
|
||||||
|
int brightnessMode = (mAutoBrightessEnabled
|
||||||
|
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
||||||
|
: HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
if ((mask & SCREEN_BRIGHT_BIT) != 0) {
|
if ((mask & SCREEN_BRIGHT_BIT) != 0) {
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT, value);
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT, value,
|
||||||
|
brightnessMode);
|
||||||
}
|
}
|
||||||
|
brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
|
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
||||||
|
: HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
if ((mask & BUTTON_BRIGHT_BIT) != 0) {
|
if ((mask & BUTTON_BRIGHT_BIT) != 0) {
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, value);
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, value,
|
||||||
|
brightnessMode);
|
||||||
}
|
}
|
||||||
if ((mask & KEYBOARD_BRIGHT_BIT) != 0) {
|
if ((mask & KEYBOARD_BRIGHT_BIT) != 0) {
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, value);
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, value,
|
||||||
|
brightnessMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1986,8 +2000,11 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
startAnimation = true;
|
startAnimation = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int brightnessMode = (mAutoBrightessEnabled
|
||||||
|
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
||||||
|
: HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT,
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT,
|
||||||
lcdValue);
|
lcdValue, brightnessMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ANIMATE_BUTTON_LIGHTS) {
|
if (ANIMATE_BUTTON_LIGHTS) {
|
||||||
@@ -1997,8 +2014,11 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
startAnimation = true;
|
startAnimation = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
|
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
||||||
|
: HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS,
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS,
|
||||||
buttonValue);
|
buttonValue, brightnessMode);
|
||||||
}
|
}
|
||||||
if (ANIMATE_KEYBOARD_LIGHTS) {
|
if (ANIMATE_KEYBOARD_LIGHTS) {
|
||||||
if (mKeyboardBrightness.setTargetLocked(keyboardValue,
|
if (mKeyboardBrightness.setTargetLocked(keyboardValue,
|
||||||
@@ -2007,8 +2027,11 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
startAnimation = true;
|
startAnimation = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
|
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
||||||
|
: HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
||||||
keyboardValue);
|
keyboardValue, brightnessMode);
|
||||||
}
|
}
|
||||||
if (startAnimation) {
|
if (startAnimation) {
|
||||||
if (mDebugLightSensor) {
|
if (mDebugLightSensor) {
|
||||||
@@ -2329,10 +2352,12 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
|
||||||
// Don't let applications turn the screen all the way off
|
// Don't let applications turn the screen all the way off
|
||||||
brightness = Math.max(brightness, Power.BRIGHTNESS_DIM);
|
brightness = Math.max(brightness, Power.BRIGHTNESS_DIM);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT, brightness);
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT, brightness,
|
||||||
|
HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
||||||
(mKeyboardVisible ? brightness : 0));
|
(mKeyboardVisible ? brightness : 0), HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, brightness);
|
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, brightness,
|
||||||
|
HardwareService.BRIGHTNESS_MODE_USER);
|
||||||
long identity = Binder.clearCallingIdentity();
|
long identity = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
mBatteryStats.noteScreenBrightness(brightness);
|
mBatteryStats.noteScreenBrightness(brightness);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ static void finalize_native(JNIEnv *env, jobject clazz, int ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
|
static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
|
||||||
int light, int colorARGB, int flashMode, int onMS, int offMS)
|
int light, int colorARGB, int flashMode, int onMS, int offMS, int brightnessMode)
|
||||||
{
|
{
|
||||||
Devices* devices = (Devices*)ptr;
|
Devices* devices = (Devices*)ptr;
|
||||||
light_state_t state;
|
light_state_t state;
|
||||||
@@ -115,6 +115,7 @@ static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
|
|||||||
state.flashMode = flashMode;
|
state.flashMode = flashMode;
|
||||||
state.flashOnMS = onMS;
|
state.flashOnMS = onMS;
|
||||||
state.flashOffMS = offMS;
|
state.flashOffMS = offMS;
|
||||||
|
state.brightnessMode = brightnessMode;
|
||||||
|
|
||||||
devices->lights[light]->set_light(devices->lights[light], &state);
|
devices->lights[light]->set_light(devices->lights[light], &state);
|
||||||
}
|
}
|
||||||
@@ -134,7 +135,7 @@ static void vibratorOff(JNIEnv *env, jobject clazz)
|
|||||||
static JNINativeMethod method_table[] = {
|
static JNINativeMethod method_table[] = {
|
||||||
{ "init_native", "()I", (void*)init_native },
|
{ "init_native", "()I", (void*)init_native },
|
||||||
{ "finalize_native", "(I)V", (void*)finalize_native },
|
{ "finalize_native", "(I)V", (void*)finalize_native },
|
||||||
{ "setLight_native", "(IIIIII)V", (void*)setLight_native },
|
{ "setLight_native", "(IIIIIII)V", (void*)setLight_native },
|
||||||
{ "vibratorOn", "(J)V", (void*)vibratorOn },
|
{ "vibratorOn", "(J)V", (void*)vibratorOn },
|
||||||
{ "vibratorOff", "()V", (void*)vibratorOff }
|
{ "vibratorOff", "()V", (void*)vibratorOff }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user