Merge "Add config to force display to transition to off after doze" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cb423e42b3
@@ -1132,6 +1132,15 @@ public final class Display {
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -1862,6 +1862,11 @@
|
||||
states. -->
|
||||
<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
|
||||
device from the display on/off state.
|
||||
|
||||
|
||||
@@ -3064,6 +3064,7 @@
|
||||
<java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" />
|
||||
<java-symbol type="integer" name="config_inCallNotificationVolumeRelative" />
|
||||
<java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" />
|
||||
<java-symbol type="bool" name="config_displayTransitionOffAfterDoze" />
|
||||
<java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" />
|
||||
<java-symbol type="string" name="config_headlineFontFamily" />
|
||||
<java-symbol type="string" name="config_headlineFontFamilyLight" />
|
||||
|
||||
@@ -165,6 +165,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// a stylish color fade animation instead.
|
||||
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.
|
||||
// Initially null until the first call to requestPowerState.
|
||||
// Guarded by mLock.
|
||||
@@ -410,6 +416,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mColorFadeFadesConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_animateScreenLights);
|
||||
|
||||
mTransitionOffAfterDozeConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_displayTransitionOffAfterDoze);
|
||||
|
||||
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
|
||||
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
if (mProximitySensor != null) {
|
||||
@@ -877,6 +886,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
}
|
||||
|
||||
private boolean setScreenState(int state) {
|
||||
return setScreenState(state, false /*force*/);
|
||||
}
|
||||
|
||||
private boolean setScreenState(int state, boolean force) {
|
||||
final boolean isOff = (state == Display.STATE_OFF);
|
||||
if (mPowerState.getScreenState() != state) {
|
||||
|
||||
@@ -887,9 +900,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_TURNING_OFF;
|
||||
blockScreenOff();
|
||||
mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker);
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
} else if (mPendingScreenOffUnblocker != null) {
|
||||
|
||||
// Abort doing the state change until screen off is unblocked.
|
||||
return false;
|
||||
}
|
||||
@@ -968,6 +989,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
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
|
||||
// finish. Then finish up now to prevent a jarring transition back
|
||||
// to screen on if we skipped blocking screen on as usual.
|
||||
|
||||
Reference in New Issue
Block a user