Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -995,6 +995,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } break; case MULTI_PRESS_POWER_BRIGHTNESS_BOOST: Slog.i(TAG, "Starting brightness boost."); if (!interactive) { wakeUpFromPowerKey(eventTime); } mPowerManager.boostScreenBrightness(eventTime); break; } Loading services/core/java/com/android/server/display/DisplayPowerController.java +10 −3 Original line number Diff line number Diff line Loading @@ -570,11 +570,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call state = mPowerState.getScreenState(); // Use zero brightness when screen is off. // Use full brightness when screen brightness is boosted. if (state == Display.STATE_OFF) { brightness = PowerManager.BRIGHTNESS_OFF; } else if (mPowerRequest.boostScreenBrightness) { brightness = PowerManager.BRIGHTNESS_ON; } // Use default brightness when dozing unless overridden. Loading @@ -592,6 +589,16 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mPowerRequest.screenAutoBrightnessAdjustment); } // 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. boolean slowChange = false; if (brightness < 0) { Loading services/core/java/com/android/server/power/PowerManagerService.java +51 −33 Original line number Diff line number Diff line Loading @@ -1234,6 +1234,7 @@ public final class PowerManagerService extends SystemService // Phase 0: Basic state updates. updateIsPoweredLocked(mDirty); updateStayOnLocked(mDirty); updateScreenBrightnessBoostLocked(mDirty); // Phase 1: Update wakefulness. // Loop because the wake lock and user activity computations are influenced Loading Loading @@ -1465,7 +1466,8 @@ public final class PowerManagerService extends SystemService private void updateUserActivitySummaryLocked(long now, int dirty) { // Update the status of the user activity timeout timer. 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); long nextTimeout = 0; Loading Loading @@ -1641,7 +1643,8 @@ public final class PowerManagerService extends SystemService || mProximityPositive || (mWakeLockSummary & WAKE_LOCK_STAY_AWAKE) != 0 || (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) != 0; | USER_ACTIVITY_SCREEN_DIM)) != 0 || mScreenBrightnessBoostInProgress; } /** Loading Loading @@ -1828,9 +1831,6 @@ public final class PowerManagerService extends SystemService | DIRTY_SETTINGS | DIRTY_SCREEN_BRIGHTNESS_BOOST)) != 0) { mDisplayPowerRequest.policy = getDesiredScreenPolicyLocked(); // Handle screen brightness boost timeout. updateScreenBrightnessBoostLocked(); // Determine appropriate screen brightness and auto-brightness adjustments. int screenBrightness = mScreenBrightnessSettingDefault; float screenAutoBrightnessAdjustment = 0.0f; Loading Loading @@ -1879,7 +1879,7 @@ public final class PowerManagerService extends SystemService } mDisplayReady = mDisplayManagerInternal.requestPowerState(mDisplayPowerRequest, mRequestWaitForNegativeProximity) && !mScreenBrightnessBoostInProgress; mRequestWaitForNegativeProximity); mRequestWaitForNegativeProximity = false; if (DEBUG_SPEW) { Loading @@ -1896,13 +1896,15 @@ public final class PowerManagerService extends SystemService return mDisplayReady && !oldDisplayReady; } private void updateScreenBrightnessBoostLocked() { private void updateScreenBrightnessBoostLocked(int dirty) { if ((dirty & DIRTY_SCREEN_BRIGHTNESS_BOOST) != 0) { if (mScreenBrightnessBoostInProgress) { final long now = SystemClock.uptimeMillis(); mHandler.removeMessages(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT); if (mLastScreenBrightnessBoostTime > mLastSleepTime) { final long boostTimeout = mLastScreenBrightnessBoostTime + SCREEN_BRIGHTNESS_BOOST_TIMEOUT; if (boostTimeout > SystemClock.uptimeMillis()) { if (boostTimeout > now) { Message msg = mHandler.obtainMessage(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT); msg.setAsynchronous(true); mHandler.sendMessageAtTime(msg, boostTimeout); Loading @@ -1910,6 +1912,9 @@ public final class PowerManagerService extends SystemService } } mScreenBrightnessBoostInProgress = false; userActivityNoUpdateLocked(now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); } } } Loading Loading @@ -1940,7 +1945,8 @@ public final class PowerManagerService extends SystemService if ((mWakeLockSummary & WAKE_LOCK_SCREEN_BRIGHT) != 0 || (mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0 || !mBootCompleted) { || !mBootCompleted || mScreenBrightnessBoostInProgress) { return DisplayPowerRequest.POLICY_BRIGHT; } Loading Loading @@ -2037,16 +2043,14 @@ public final class PowerManagerService extends SystemService final boolean needWakeLockSuspendBlocker = ((mWakeLockSummary & WAKE_LOCK_CPU) != 0); final boolean needDisplaySuspendBlocker = needDisplaySuspendBlockerLocked(); final boolean autoSuspend = !needDisplaySuspendBlocker; final boolean interactive = mDisplayPowerRequest.isBrightOrDim(); // Disable auto-suspend if needed. if (!autoSuspend) { if (mDecoupleHalAutoSuspendModeFromDisplayConfig) { // FIXME We should consider just leaving auto-suspend enabled forever since // we already hold the necessary wakelocks. if (!autoSuspend && mDecoupleHalAutoSuspendModeFromDisplayConfig) { setHalAutoSuspendModeLocked(false); } if (mDecoupleHalInteractiveModeFromDisplayConfig) { setHalInteractiveModeLocked(true); } } // First acquire suspend blockers if needed. if (needWakeLockSuspendBlocker && !mHoldingWakeLockSuspendBlocker) { Loading @@ -2058,6 +2062,22 @@ public final class PowerManagerService extends SystemService 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. if (!needWakeLockSuspendBlocker && mHoldingWakeLockSuspendBlocker) { mWakeLockSuspendBlocker.release(); Loading @@ -2069,15 +2089,10 @@ public final class PowerManagerService extends SystemService } // Enable auto-suspend if needed. if (autoSuspend) { if (mDecoupleHalInteractiveModeFromDisplayConfig) { setHalInteractiveModeLocked(false); } if (mDecoupleHalAutoSuspendModeFromDisplayConfig) { if (autoSuspend && mDecoupleHalAutoSuspendModeFromDisplayConfig) { setHalAutoSuspendModeLocked(true); } } } /** * Return true if we must keep a suspend blocker active on behalf of the display. Loading @@ -2097,6 +2112,9 @@ public final class PowerManagerService extends SystemService return true; } } if (mScreenBrightnessBoostInProgress) { return true; } // Let the system suspend if the screen is off or dozing. return false; } Loading Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -995,6 +995,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } break; case MULTI_PRESS_POWER_BRIGHTNESS_BOOST: Slog.i(TAG, "Starting brightness boost."); if (!interactive) { wakeUpFromPowerKey(eventTime); } mPowerManager.boostScreenBrightness(eventTime); break; } Loading
services/core/java/com/android/server/display/DisplayPowerController.java +10 −3 Original line number Diff line number Diff line Loading @@ -570,11 +570,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call state = mPowerState.getScreenState(); // Use zero brightness when screen is off. // Use full brightness when screen brightness is boosted. if (state == Display.STATE_OFF) { brightness = PowerManager.BRIGHTNESS_OFF; } else if (mPowerRequest.boostScreenBrightness) { brightness = PowerManager.BRIGHTNESS_ON; } // Use default brightness when dozing unless overridden. Loading @@ -592,6 +589,16 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mPowerRequest.screenAutoBrightnessAdjustment); } // 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. boolean slowChange = false; if (brightness < 0) { Loading
services/core/java/com/android/server/power/PowerManagerService.java +51 −33 Original line number Diff line number Diff line Loading @@ -1234,6 +1234,7 @@ public final class PowerManagerService extends SystemService // Phase 0: Basic state updates. updateIsPoweredLocked(mDirty); updateStayOnLocked(mDirty); updateScreenBrightnessBoostLocked(mDirty); // Phase 1: Update wakefulness. // Loop because the wake lock and user activity computations are influenced Loading Loading @@ -1465,7 +1466,8 @@ public final class PowerManagerService extends SystemService private void updateUserActivitySummaryLocked(long now, int dirty) { // Update the status of the user activity timeout timer. 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); long nextTimeout = 0; Loading Loading @@ -1641,7 +1643,8 @@ public final class PowerManagerService extends SystemService || mProximityPositive || (mWakeLockSummary & WAKE_LOCK_STAY_AWAKE) != 0 || (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) != 0; | USER_ACTIVITY_SCREEN_DIM)) != 0 || mScreenBrightnessBoostInProgress; } /** Loading Loading @@ -1828,9 +1831,6 @@ public final class PowerManagerService extends SystemService | DIRTY_SETTINGS | DIRTY_SCREEN_BRIGHTNESS_BOOST)) != 0) { mDisplayPowerRequest.policy = getDesiredScreenPolicyLocked(); // Handle screen brightness boost timeout. updateScreenBrightnessBoostLocked(); // Determine appropriate screen brightness and auto-brightness adjustments. int screenBrightness = mScreenBrightnessSettingDefault; float screenAutoBrightnessAdjustment = 0.0f; Loading Loading @@ -1879,7 +1879,7 @@ public final class PowerManagerService extends SystemService } mDisplayReady = mDisplayManagerInternal.requestPowerState(mDisplayPowerRequest, mRequestWaitForNegativeProximity) && !mScreenBrightnessBoostInProgress; mRequestWaitForNegativeProximity); mRequestWaitForNegativeProximity = false; if (DEBUG_SPEW) { Loading @@ -1896,13 +1896,15 @@ public final class PowerManagerService extends SystemService return mDisplayReady && !oldDisplayReady; } private void updateScreenBrightnessBoostLocked() { private void updateScreenBrightnessBoostLocked(int dirty) { if ((dirty & DIRTY_SCREEN_BRIGHTNESS_BOOST) != 0) { if (mScreenBrightnessBoostInProgress) { final long now = SystemClock.uptimeMillis(); mHandler.removeMessages(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT); if (mLastScreenBrightnessBoostTime > mLastSleepTime) { final long boostTimeout = mLastScreenBrightnessBoostTime + SCREEN_BRIGHTNESS_BOOST_TIMEOUT; if (boostTimeout > SystemClock.uptimeMillis()) { if (boostTimeout > now) { Message msg = mHandler.obtainMessage(MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT); msg.setAsynchronous(true); mHandler.sendMessageAtTime(msg, boostTimeout); Loading @@ -1910,6 +1912,9 @@ public final class PowerManagerService extends SystemService } } mScreenBrightnessBoostInProgress = false; userActivityNoUpdateLocked(now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); } } } Loading Loading @@ -1940,7 +1945,8 @@ public final class PowerManagerService extends SystemService if ((mWakeLockSummary & WAKE_LOCK_SCREEN_BRIGHT) != 0 || (mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0 || !mBootCompleted) { || !mBootCompleted || mScreenBrightnessBoostInProgress) { return DisplayPowerRequest.POLICY_BRIGHT; } Loading Loading @@ -2037,16 +2043,14 @@ public final class PowerManagerService extends SystemService final boolean needWakeLockSuspendBlocker = ((mWakeLockSummary & WAKE_LOCK_CPU) != 0); final boolean needDisplaySuspendBlocker = needDisplaySuspendBlockerLocked(); final boolean autoSuspend = !needDisplaySuspendBlocker; final boolean interactive = mDisplayPowerRequest.isBrightOrDim(); // Disable auto-suspend if needed. if (!autoSuspend) { if (mDecoupleHalAutoSuspendModeFromDisplayConfig) { // FIXME We should consider just leaving auto-suspend enabled forever since // we already hold the necessary wakelocks. if (!autoSuspend && mDecoupleHalAutoSuspendModeFromDisplayConfig) { setHalAutoSuspendModeLocked(false); } if (mDecoupleHalInteractiveModeFromDisplayConfig) { setHalInteractiveModeLocked(true); } } // First acquire suspend blockers if needed. if (needWakeLockSuspendBlocker && !mHoldingWakeLockSuspendBlocker) { Loading @@ -2058,6 +2062,22 @@ public final class PowerManagerService extends SystemService 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. if (!needWakeLockSuspendBlocker && mHoldingWakeLockSuspendBlocker) { mWakeLockSuspendBlocker.release(); Loading @@ -2069,15 +2089,10 @@ public final class PowerManagerService extends SystemService } // Enable auto-suspend if needed. if (autoSuspend) { if (mDecoupleHalInteractiveModeFromDisplayConfig) { setHalInteractiveModeLocked(false); } if (mDecoupleHalAutoSuspendModeFromDisplayConfig) { if (autoSuspend && mDecoupleHalAutoSuspendModeFromDisplayConfig) { setHalAutoSuspendModeLocked(true); } } } /** * Return true if we must keep a suspend blocker active on behalf of the display. Loading @@ -2097,6 +2112,9 @@ public final class PowerManagerService extends SystemService return true; } } if (mScreenBrightnessBoostInProgress) { return true; } // Let the system suspend if the screen is off or dozing. return false; } Loading