Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions services/java/com/android/server/PowerManagerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ public class PowerManagerService extends IPowerManager.Stub
private int mAnimationSetting = ANIM_SETTING_OFF;
private boolean mAnimateCrtOff = false;
private boolean mAnimateCrtOn = false;
// When using software auto-brightness, determines whether (true) button
// and keyboard backlights should also be under automatic brightness
// control (i.e., for dimmable backlights), or (false) if they should use
// hard-coded brightness settings that timeout-to-off in subsequent screen
// power states.
private boolean mAutobrightnessButtonKeyboard;

// Must match with the ISurfaceComposer constants in C++.
private static final int ANIM_SETTING_ON = 0x01;
Expand Down Expand Up @@ -617,6 +623,8 @@ void initInThread() {
// read settings for auto-brightness
mUseSoftwareAutoBrightness = resources.getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
mAutoBrightnessButtonKeyboard = mUseSoftwareAutoBrightness && resources.getBoolean(
com.android.internal.R.bool.config_autoBrightnessButtonKeyboard);
if (mUseSoftwareAutoBrightness) {
mAutoBrightnessLevels = resources.getIntArray(
com.android.internal.R.array.config_autoBrightnessLevels);
Expand Down Expand Up @@ -822,7 +830,7 @@ public void acquireWakeLockLocked(int flags, IBinder lock, int uid, int pid, Str
switch (wl.flags & LOCK_MASK)
{
case PowerManager.FULL_WAKE_LOCK:
if (mUseSoftwareAutoBrightness) {
if (mAutoBrightnessButtonKeyboard) {
wl.minState = SCREEN_BRIGHT;
} else {
wl.minState = (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
Expand Down Expand Up @@ -1189,6 +1197,7 @@ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ " mLightSensorButtonBrightness=" + mLightSensorButtonBrightness
+ " mLightSensorKeyboardBrightness=" + mLightSensorKeyboardBrightness);
pw.println(" mUseSoftwareAutoBrightness=" + mUseSoftwareAutoBrightness);
pw.println(" mAutoBrightnessButtonKeyboard=" + mAutoBrightnessButtonKeyboard);
pw.println(" mAutoBrightessEnabled=" + mAutoBrightessEnabled);
mScreenBrightness.dump(pw, " mScreenBrightness: ");

Expand Down Expand Up @@ -1768,7 +1777,7 @@ private void setPowerState(int newState, boolean noChangeLights, int reason)
return;
}

if (!mBootCompleted && !mUseSoftwareAutoBrightness) {
if (!mBootCompleted && !mAutoBrightnessButtonKeyboard) {
newState |= ALL_BRIGHT;
}

Expand Down Expand Up @@ -2280,7 +2289,7 @@ private int applyButtonState(int state) {
}
if (mButtonBrightnessOverride >= 0) {
brightness = mButtonBrightnessOverride;
} else if (mLightSensorButtonBrightness >= 0 && mUseSoftwareAutoBrightness) {
} else if (mLightSensorButtonBrightness >= 0 && mAutoBrightnessButtonKeyboard) {
brightness = mLightSensorButtonBrightness;
}
if (brightness > 0) {
Expand All @@ -2302,7 +2311,7 @@ private int applyKeyboardState(int state) {
brightness = 0;
} else if (mButtonBrightnessOverride >= 0) {
brightness = mButtonBrightnessOverride;
} else if (mLightSensorKeyboardBrightness >= 0 && mUseSoftwareAutoBrightness) {
} else if (mLightSensorKeyboardBrightness >= 0 && mAutoBrightnessButtonKeyboard) {
brightness = mLightSensorKeyboardBrightness;
}
if (brightness > 0) {
Expand Down Expand Up @@ -2425,9 +2434,11 @@ private void userActivity(long time, long timeoutOverride, boolean noChangeLight
if (mLastEventTime <= time || force) {
mLastEventTime = time;
if ((mUserActivityAllowed && !mProximitySensorActive) || force) {
// Only turn on button backlights if a button was pressed
// and auto brightness is disabled
if (eventType == BUTTON_EVENT && !mUseSoftwareAutoBrightness) {
if (!mAutoBrightnessButtonKeyboard) {
// Turn on button (and keyboard) backlights on any event, so that they
// don't suddenly disappear when the lock screen is unlocked (OTHER_EVENT),
// and so capacitive buttons can be found on devices where they lack
// identifying surface features.
mUserState = (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
} else {
// don't clear button/keyboard backlights when the screen is touched.
Expand Down Expand Up @@ -2899,7 +2910,7 @@ void systemReady() {
// wait until sensors are enabled before turning on screen.
// some devices will not activate the light sensor properly on boot
// unless we do this.
if (mUseSoftwareAutoBrightness) {
if (mAutoBrightnessButtonKeyboard) {
// turn the screen on
setPowerState(SCREEN_BRIGHT);
} else {
Expand Down