Merge "Setting the display state to off when the default display is being changed" into tm-qpr-dev

This commit is contained in:
Rupesh Bansal
2023-01-07 02:01:21 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 5 deletions

View File

@@ -818,8 +818,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
loadFromDisplayDeviceConfig(token, info); loadFromDisplayDeviceConfig(token, info);
// Since the underlying display-device changed, we really don't know the // Since the underlying display-device changed, we really don't know the
// last command that was sent to change it's state. Lets assume it is unknown so // last command that was sent to change it's state. Lets assume it is off and we
// that we trigger a change immediately. // trigger a change immediately.
mPowerState.resetScreenState(); mPowerState.resetScreenState();
} }
if (mIsEnabled != isEnabled || mIsInTransition != isInTransition) { if (mIsEnabled != isEnabled || mIsInTransition != isInTransition) {

View File

@@ -340,12 +340,20 @@ final class DisplayPowerState {
} }
/** /**
* Resets the screen state to unknown. Useful when the underlying display-device changes for the * Resets the screen state to {@link Display#STATE_OFF}. Even though we do not know the last
* LogicalDisplay and we do not know the last state that was sent to it. * state that was sent to the underlying display-device, we assume it is off.
*
* We do not set the screen state to {@link Display#STATE_UNKNOWN} to avoid getting in the state
* where PhotonicModulator holds onto the lock. This happens because we currently try to keep
* the mScreenState and mPendingState in sync, however if the screenState is set to
* {@link Display#STATE_UNKNOWN} here, mPendingState will get progressed to this, which will
* force the PhotonicModulator thread to wait onto the lock to take it out of that state.
* b/262294651 for more info.
*/ */
void resetScreenState() { void resetScreenState() {
mScreenState = Display.STATE_UNKNOWN; mScreenState = Display.STATE_OFF;
mScreenReady = false; mScreenReady = false;
scheduleScreenUpdate();
} }
private void scheduleScreenUpdate() { private void scheduleScreenUpdate() {