Loading core/java/android/view/Display.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1132,6 +1132,15 @@ public final class Display { return state == STATE_OFF || state == STATE_DOZE_SUSPEND; return state == STATE_OFF || state == STATE_DOZE_SUSPEND; } } /** * Returns true if the display may be in a reduced operating mode while in the * specified display power state. * @hide */ public static boolean isDozeState(int state) { return state == STATE_DOZE || state == STATE_DOZE_SUSPEND; } /** /** * A mode supported by a given display. * A mode supported by a given display. * * Loading core/res/res/values/config.xml +5 −0 Original line number Original line Diff line number Diff line Loading @@ -1862,6 +1862,11 @@ states. --> states. --> <bool name="config_dozeAlwaysOnDisplayAvailable">false</bool> <bool name="config_dozeAlwaysOnDisplayAvailable">false</bool> <!-- Whether the display hardware requires we go to the off state before transitioning out of any doze states. --> <bool name="config_displayTransitionOffAfterDoze">false</bool> <!-- Power Management: Specifies whether to decouple the auto-suspend state of the <!-- Power Management: Specifies whether to decouple the auto-suspend state of the device from the display on/off state. device from the display on/off state. Loading core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3064,6 +3064,7 @@ <java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" /> <java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" /> <java-symbol type="integer" name="config_inCallNotificationVolumeRelative" /> <java-symbol type="integer" name="config_inCallNotificationVolumeRelative" /> <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" /> <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" /> <java-symbol type="bool" name="config_displayTransitionOffAfterDoze" /> <java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" /> <java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" /> <java-symbol type="string" name="config_headlineFontFamily" /> <java-symbol type="string" name="config_headlineFontFamily" /> <java-symbol type="string" name="config_headlineFontFamilyLight" /> <java-symbol type="string" name="config_headlineFontFamilyLight" /> Loading services/core/java/com/android/server/display/DisplayPowerController.java +34 −2 Original line number Original line Diff line number Diff line Loading @@ -165,6 +165,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // a stylish color fade animation instead. // a stylish color fade animation instead. private boolean mColorFadeFadesConfig; private boolean mColorFadeFadesConfig; // True if we need to transition to the off state when coming out of a doze state. // Some display hardware will show artifacts (flickers, etc) when transitioning from a doze // to a fully on state. In order to hide these, we first transition to off to let the system // animate the screen on as it normally would, which is a much smoother experience. private boolean mTransitionOffAfterDozeConfig; // The pending power request. // The pending power request. // Initially null until the first call to requestPowerState. // Initially null until the first call to requestPowerState. // Guarded by mLock. // Guarded by mLock. Loading Loading @@ -410,6 +416,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mColorFadeFadesConfig = resources.getBoolean( mColorFadeFadesConfig = resources.getBoolean( com.android.internal.R.bool.config_animateScreenLights); com.android.internal.R.bool.config_animateScreenLights); mTransitionOffAfterDozeConfig = resources.getBoolean( com.android.internal.R.bool.config_displayTransitionOffAfterDoze); if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) { if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) { mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (mProximitySensor != null) { if (mProximitySensor != null) { Loading Loading @@ -877,6 +886,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } private boolean setScreenState(int state) { private boolean setScreenState(int state) { return setScreenState(state, false /*force*/); } private boolean setScreenState(int state, boolean force) { final boolean isOff = (state == Display.STATE_OFF); final boolean isOff = (state == Display.STATE_OFF); if (mPowerState.getScreenState() != state) { if (mPowerState.getScreenState() != state) { Loading @@ -887,9 +900,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_TURNING_OFF; mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_TURNING_OFF; blockScreenOff(); blockScreenOff(); mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker); mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker); if (force) { // If we're forcing the power state transition then immediately // unblock the screen off event. This keeps the lifecycle consistent, // so WindowManagerPolicy will always see screenTurningOff before // screenTurnedOff, but we don't actually block on them for the state // change. unblockScreenOff(); } else { return false; return false; } } else if (mPendingScreenOffUnblocker != null) { } else if (mPendingScreenOffUnblocker != null) { // Abort doing the state change until screen off is unblocked. // Abort doing the state change until screen off is unblocked. return false; return false; } } Loading Loading @@ -968,6 +989,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mPendingScreenOff = false; mPendingScreenOff = false; } } if (mTransitionOffAfterDozeConfig && Display.isDozeState(mPowerState.getScreenState()) && !Display.isDozeState(target)) { setScreenState(Display.STATE_OFF, true /*force*/); // Skip the screen off animation and add a black surface to hide the // contents of the screen. This will also trigger another power state update so that we // end up converging on the target state. mColorFadeOffAnimator.end(); return; } // If we were in the process of turning off the screen but didn't quite // If we were in the process of turning off the screen but didn't quite // finish. Then finish up now to prevent a jarring transition back // finish. Then finish up now to prevent a jarring transition back // to screen on if we skipped blocking screen on as usual. // to screen on if we skipped blocking screen on as usual. Loading Loading
core/java/android/view/Display.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1132,6 +1132,15 @@ public final class Display { return state == STATE_OFF || state == STATE_DOZE_SUSPEND; return state == STATE_OFF || state == STATE_DOZE_SUSPEND; } } /** * Returns true if the display may be in a reduced operating mode while in the * specified display power state. * @hide */ public static boolean isDozeState(int state) { return state == STATE_DOZE || state == STATE_DOZE_SUSPEND; } /** /** * A mode supported by a given display. * A mode supported by a given display. * * Loading
core/res/res/values/config.xml +5 −0 Original line number Original line Diff line number Diff line Loading @@ -1862,6 +1862,11 @@ states. --> states. --> <bool name="config_dozeAlwaysOnDisplayAvailable">false</bool> <bool name="config_dozeAlwaysOnDisplayAvailable">false</bool> <!-- Whether the display hardware requires we go to the off state before transitioning out of any doze states. --> <bool name="config_displayTransitionOffAfterDoze">false</bool> <!-- Power Management: Specifies whether to decouple the auto-suspend state of the <!-- Power Management: Specifies whether to decouple the auto-suspend state of the device from the display on/off state. device from the display on/off state. Loading
core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3064,6 +3064,7 @@ <java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" /> <java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" /> <java-symbol type="integer" name="config_inCallNotificationVolumeRelative" /> <java-symbol type="integer" name="config_inCallNotificationVolumeRelative" /> <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" /> <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" /> <java-symbol type="bool" name="config_displayTransitionOffAfterDoze" /> <java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" /> <java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" /> <java-symbol type="string" name="config_headlineFontFamily" /> <java-symbol type="string" name="config_headlineFontFamily" /> <java-symbol type="string" name="config_headlineFontFamilyLight" /> <java-symbol type="string" name="config_headlineFontFamilyLight" /> Loading
services/core/java/com/android/server/display/DisplayPowerController.java +34 −2 Original line number Original line Diff line number Diff line Loading @@ -165,6 +165,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // a stylish color fade animation instead. // a stylish color fade animation instead. private boolean mColorFadeFadesConfig; private boolean mColorFadeFadesConfig; // True if we need to transition to the off state when coming out of a doze state. // Some display hardware will show artifacts (flickers, etc) when transitioning from a doze // to a fully on state. In order to hide these, we first transition to off to let the system // animate the screen on as it normally would, which is a much smoother experience. private boolean mTransitionOffAfterDozeConfig; // The pending power request. // The pending power request. // Initially null until the first call to requestPowerState. // Initially null until the first call to requestPowerState. // Guarded by mLock. // Guarded by mLock. Loading Loading @@ -410,6 +416,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mColorFadeFadesConfig = resources.getBoolean( mColorFadeFadesConfig = resources.getBoolean( com.android.internal.R.bool.config_animateScreenLights); com.android.internal.R.bool.config_animateScreenLights); mTransitionOffAfterDozeConfig = resources.getBoolean( com.android.internal.R.bool.config_displayTransitionOffAfterDoze); if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) { if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) { mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (mProximitySensor != null) { if (mProximitySensor != null) { Loading Loading @@ -877,6 +886,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } private boolean setScreenState(int state) { private boolean setScreenState(int state) { return setScreenState(state, false /*force*/); } private boolean setScreenState(int state, boolean force) { final boolean isOff = (state == Display.STATE_OFF); final boolean isOff = (state == Display.STATE_OFF); if (mPowerState.getScreenState() != state) { if (mPowerState.getScreenState() != state) { Loading @@ -887,9 +900,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_TURNING_OFF; mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_TURNING_OFF; blockScreenOff(); blockScreenOff(); mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker); mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker); if (force) { // If we're forcing the power state transition then immediately // unblock the screen off event. This keeps the lifecycle consistent, // so WindowManagerPolicy will always see screenTurningOff before // screenTurnedOff, but we don't actually block on them for the state // change. unblockScreenOff(); } else { return false; return false; } } else if (mPendingScreenOffUnblocker != null) { } else if (mPendingScreenOffUnblocker != null) { // Abort doing the state change until screen off is unblocked. // Abort doing the state change until screen off is unblocked. return false; return false; } } Loading Loading @@ -968,6 +989,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mPendingScreenOff = false; mPendingScreenOff = false; } } if (mTransitionOffAfterDozeConfig && Display.isDozeState(mPowerState.getScreenState()) && !Display.isDozeState(target)) { setScreenState(Display.STATE_OFF, true /*force*/); // Skip the screen off animation and add a black surface to hide the // contents of the screen. This will also trigger another power state update so that we // end up converging on the target state. mColorFadeOffAnimator.end(); return; } // If we were in the process of turning off the screen but didn't quite // If we were in the process of turning off the screen but didn't quite // finish. Then finish up now to prevent a jarring transition back // finish. Then finish up now to prevent a jarring transition back // to screen on if we skipped blocking screen on as usual. // to screen on if we skipped blocking screen on as usual. Loading