am 1cbff0e3: Merge "Improve screen brightness boost behavior." into lmp-sprout-dev
* commit '1cbff0e310b0fba6b25ca1c1e14eaefeabdee0d9': Improve screen brightness boost behavior.
This commit is contained in:
@@ -998,6 +998,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MULTI_PRESS_POWER_BRIGHTNESS_BOOST:
|
case MULTI_PRESS_POWER_BRIGHTNESS_BOOST:
|
||||||
|
Slog.i(TAG, "Starting brightness boost.");
|
||||||
|
if (!interactive) {
|
||||||
|
wakeUpFromPowerKey(eventTime);
|
||||||
|
}
|
||||||
mPowerManager.boostScreenBrightness(eventTime);
|
mPowerManager.boostScreenBrightness(eventTime);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -582,11 +582,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
state = mPowerState.getScreenState();
|
state = mPowerState.getScreenState();
|
||||||
|
|
||||||
// Use zero brightness when screen is off.
|
// Use zero brightness when screen is off.
|
||||||
// Use full brightness when screen brightness is boosted.
|
|
||||||
if (state == Display.STATE_OFF) {
|
if (state == Display.STATE_OFF) {
|
||||||
brightness = PowerManager.BRIGHTNESS_OFF;
|
brightness = PowerManager.BRIGHTNESS_OFF;
|
||||||
} else if (mPowerRequest.boostScreenBrightness) {
|
|
||||||
brightness = PowerManager.BRIGHTNESS_ON;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure auto-brightness.
|
// Configure auto-brightness.
|
||||||
@@ -601,6 +598,16 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
mPowerRequest.screenAutoBrightnessAdjustment, state != Display.STATE_ON);
|
mPowerRequest.screenAutoBrightnessAdjustment, state != Display.STATE_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply brightness boost.
|
||||||
|
// We do this here after configuring auto-brightness so that we don't
|
||||||
|
// disable the light sensor during this temporary state. That way when
|
||||||
|
// boost ends we will be able to resume normal auto-brightness behavior
|
||||||
|
// without any delay.
|
||||||
|
if (mPowerRequest.boostScreenBrightness
|
||||||
|
&& brightness != PowerManager.BRIGHTNESS_OFF) {
|
||||||
|
brightness = PowerManager.BRIGHTNESS_ON;
|
||||||
|
}
|
||||||
|
|
||||||
// Apply auto-brightness.
|
// Apply auto-brightness.
|
||||||
boolean slowChange = false;
|
boolean slowChange = false;
|
||||||
if (brightness < 0) {
|
if (brightness < 0) {
|
||||||
|
|||||||
@@ -1234,6 +1234,7 @@ public final class PowerManagerService extends SystemService
|
|||||||
// Phase 0: Basic state updates.
|
// Phase 0: Basic state updates.
|
||||||
updateIsPoweredLocked(mDirty);
|
updateIsPoweredLocked(mDirty);
|
||||||
updateStayOnLocked(mDirty);
|
updateStayOnLocked(mDirty);
|
||||||
|
updateScreenBrightnessBoostLocked(mDirty);
|
||||||
|
|
||||||
// Phase 1: Update wakefulness.
|
// Phase 1: Update wakefulness.
|
||||||
// Loop because the wake lock and user activity computations are influenced
|
// Loop because the wake lock and user activity computations are influenced
|
||||||
@@ -1465,7 +1466,8 @@ public final class PowerManagerService extends SystemService
|
|||||||
private void updateUserActivitySummaryLocked(long now, int dirty) {
|
private void updateUserActivitySummaryLocked(long now, int dirty) {
|
||||||
// Update the status of the user activity timeout timer.
|
// Update the status of the user activity timeout timer.
|
||||||
if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY
|
if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY
|
||||||
| DIRTY_WAKEFULNESS | DIRTY_SETTINGS)) != 0) {
|
| DIRTY_WAKEFULNESS | DIRTY_SETTINGS
|
||||||
|
| DIRTY_SCREEN_BRIGHTNESS_BOOST)) != 0) {
|
||||||
mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT);
|
mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT);
|
||||||
|
|
||||||
long nextTimeout = 0;
|
long nextTimeout = 0;
|
||||||
@@ -1641,7 +1643,8 @@ public final class PowerManagerService extends SystemService
|
|||||||
|| mProximityPositive
|
|| mProximityPositive
|
||||||
|| (mWakeLockSummary & WAKE_LOCK_STAY_AWAKE) != 0
|
|| (mWakeLockSummary & WAKE_LOCK_STAY_AWAKE) != 0
|
||||||
|| (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT
|
|| (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT
|
||||||
| USER_ACTIVITY_SCREEN_DIM)) != 0;
|
| USER_ACTIVITY_SCREEN_DIM)) != 0
|
||||||
|
|| mScreenBrightnessBoostInProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1828,9 +1831,6 @@ public final class PowerManagerService extends SystemService
|
|||||||
| DIRTY_SETTINGS | DIRTY_SCREEN_BRIGHTNESS_BOOST)) != 0) {
|
| DIRTY_SETTINGS | DIRTY_SCREEN_BRIGHTNESS_BOOST)) != 0) {
|
||||||
mDisplayPowerRequest.policy = getDesiredScreenPolicyLocked();
|
mDisplayPowerRequest.policy = getDesiredScreenPolicyLocked();
|
||||||
|
|
||||||
// Handle screen brightness boost timeout.
|
|
||||||
updateScreenBrightnessBoostLocked();
|
|
||||||
|
|
||||||
// Determine appropriate screen brightness and auto-brightness adjustments.
|
// Determine appropriate screen brightness and auto-brightness adjustments.
|
||||||
int screenBrightness = mScreenBrightnessSettingDefault;
|
int screenBrightness = mScreenBrightnessSettingDefault;
|
||||||
float screenAutoBrightnessAdjustment = 0.0f;
|
float screenAutoBrightnessAdjustment = 0.0f;
|
||||||
@@ -1879,7 +1879,7 @@ public final class PowerManagerService extends SystemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
mDisplayReady = mDisplayManagerInternal.requestPowerState(mDisplayPowerRequest,
|
mDisplayReady = mDisplayManagerInternal.requestPowerState(mDisplayPowerRequest,
|
||||||
mRequestWaitForNegativeProximity) && !mScreenBrightnessBoostInProgress;
|
mRequestWaitForNegativeProximity);
|
||||||
mRequestWaitForNegativeProximity = false;
|
mRequestWaitForNegativeProximity = false;
|
||||||
|
|
||||||
if (DEBUG_SPEW) {
|
if (DEBUG_SPEW) {
|
||||||
@@ -1896,20 +1896,25 @@ public final class PowerManagerService extends SystemService
|
|||||||
return mDisplayReady && !oldDisplayReady;
|
return mDisplayReady && !oldDisplayReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateScreenBrightnessBoostLocked() {
|
private void updateScreenBrightnessBoostLocked(int dirty) {
|
||||||
if (mScreenBrightnessBoostInProgress) {
|
if ((dirty & DIRTY_SCREEN_BRIGHTNESS_BOOST) != 0) {
|
||||||
mHandler.removeMessages(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT);
|
if (mScreenBrightnessBoostInProgress) {
|
||||||
if (mLastScreenBrightnessBoostTime > mLastSleepTime) {
|
final long now = SystemClock.uptimeMillis();
|
||||||
final long boostTimeout = mLastScreenBrightnessBoostTime +
|
mHandler.removeMessages(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT);
|
||||||
SCREEN_BRIGHTNESS_BOOST_TIMEOUT;
|
if (mLastScreenBrightnessBoostTime > mLastSleepTime) {
|
||||||
if (boostTimeout > SystemClock.uptimeMillis()) {
|
final long boostTimeout = mLastScreenBrightnessBoostTime +
|
||||||
Message msg = mHandler.obtainMessage(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT);
|
SCREEN_BRIGHTNESS_BOOST_TIMEOUT;
|
||||||
msg.setAsynchronous(true);
|
if (boostTimeout > now) {
|
||||||
mHandler.sendMessageAtTime(msg, boostTimeout);
|
Message msg = mHandler.obtainMessage(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT);
|
||||||
return;
|
msg.setAsynchronous(true);
|
||||||
|
mHandler.sendMessageAtTime(msg, boostTimeout);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
mScreenBrightnessBoostInProgress = false;
|
||||||
|
userActivityNoUpdateLocked(now,
|
||||||
|
PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
|
||||||
}
|
}
|
||||||
mScreenBrightnessBoostInProgress = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1940,7 +1945,8 @@ public final class PowerManagerService extends SystemService
|
|||||||
|
|
||||||
if ((mWakeLockSummary & WAKE_LOCK_SCREEN_BRIGHT) != 0
|
if ((mWakeLockSummary & WAKE_LOCK_SCREEN_BRIGHT) != 0
|
||||||
|| (mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0
|
|| (mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0
|
||||||
|| !mBootCompleted) {
|
|| !mBootCompleted
|
||||||
|
|| mScreenBrightnessBoostInProgress) {
|
||||||
return DisplayPowerRequest.POLICY_BRIGHT;
|
return DisplayPowerRequest.POLICY_BRIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2037,15 +2043,13 @@ public final class PowerManagerService extends SystemService
|
|||||||
final boolean needWakeLockSuspendBlocker = ((mWakeLockSummary & WAKE_LOCK_CPU) != 0);
|
final boolean needWakeLockSuspendBlocker = ((mWakeLockSummary & WAKE_LOCK_CPU) != 0);
|
||||||
final boolean needDisplaySuspendBlocker = needDisplaySuspendBlockerLocked();
|
final boolean needDisplaySuspendBlocker = needDisplaySuspendBlockerLocked();
|
||||||
final boolean autoSuspend = !needDisplaySuspendBlocker;
|
final boolean autoSuspend = !needDisplaySuspendBlocker;
|
||||||
|
final boolean interactive = mDisplayPowerRequest.isBrightOrDim();
|
||||||
|
|
||||||
// Disable auto-suspend if needed.
|
// Disable auto-suspend if needed.
|
||||||
if (!autoSuspend) {
|
// FIXME We should consider just leaving auto-suspend enabled forever since
|
||||||
if (mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
// we already hold the necessary wakelocks.
|
||||||
setHalAutoSuspendModeLocked(false);
|
if (!autoSuspend && mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
||||||
}
|
setHalAutoSuspendModeLocked(false);
|
||||||
if (mDecoupleHalInteractiveModeFromDisplayConfig) {
|
|
||||||
setHalInteractiveModeLocked(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// First acquire suspend blockers if needed.
|
// First acquire suspend blockers if needed.
|
||||||
@@ -2058,6 +2062,22 @@ public final class PowerManagerService extends SystemService
|
|||||||
mHoldingDisplaySuspendBlocker = true;
|
mHoldingDisplaySuspendBlocker = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inform the power HAL about interactive mode.
|
||||||
|
// Although we could set interactive strictly based on the wakefulness
|
||||||
|
// as reported by isInteractive(), it is actually more desirable to track
|
||||||
|
// the display policy state instead so that the interactive state observed
|
||||||
|
// by the HAL more accurately tracks transitions between AWAKE and DOZING.
|
||||||
|
// Refer to getDesiredScreenPolicyLocked() for details.
|
||||||
|
if (mDecoupleHalInteractiveModeFromDisplayConfig) {
|
||||||
|
// When becoming non-interactive, we want to defer sending this signal
|
||||||
|
// until the display is actually ready so that all transitions have
|
||||||
|
// completed. This is probably a good sign that things have gotten
|
||||||
|
// too tangled over here...
|
||||||
|
if (interactive || mDisplayReady) {
|
||||||
|
setHalInteractiveModeLocked(interactive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Then release suspend blockers if needed.
|
// Then release suspend blockers if needed.
|
||||||
if (!needWakeLockSuspendBlocker && mHoldingWakeLockSuspendBlocker) {
|
if (!needWakeLockSuspendBlocker && mHoldingWakeLockSuspendBlocker) {
|
||||||
mWakeLockSuspendBlocker.release();
|
mWakeLockSuspendBlocker.release();
|
||||||
@@ -2069,13 +2089,8 @@ public final class PowerManagerService extends SystemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable auto-suspend if needed.
|
// Enable auto-suspend if needed.
|
||||||
if (autoSuspend) {
|
if (autoSuspend && mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
||||||
if (mDecoupleHalInteractiveModeFromDisplayConfig) {
|
setHalAutoSuspendModeLocked(true);
|
||||||
setHalInteractiveModeLocked(false);
|
|
||||||
}
|
|
||||||
if (mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
|
||||||
setHalAutoSuspendModeLocked(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2097,6 +2112,9 @@ public final class PowerManagerService extends SystemService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mScreenBrightnessBoostInProgress) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// Let the system suspend if the screen is off or dozing.
|
// Let the system suspend if the screen is off or dozing.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user