Move LogicalDisplay.isEnabled calculation to DPC.

Move the logicalDisplay.isEnabled() check from being a one-off
check in DisplayManagerService to being part of the display-power
calculation in DisplayPowerController.

Also:
- Change initial value of mDisplayState to UNKNOWN so that we dont
send displayState requests until the display's power state has been
initialized by DisplayPowerController.
- Sent the displayState to SurfaceControl when the
previous state was UNKNOWN. This is needed to ensure the second
display on multi-display devices can be set to OFF by default.

Test: Manually verify no OFF state is sent during boot-up on
single-display devices
Test: atest com.android.server.display
Bug: 181314849
Bug: 178713651

Change-Id: If3b0880b173bc11974f1a61d159d7a4ca9a0c159
This commit is contained in:
Santos Cordon
2021-03-08 13:28:45 +00:00
parent 85399be2db
commit 33b90a3683
3 changed files with 13 additions and 10 deletions

View File

@@ -1128,7 +1128,7 @@ public final class DisplayManagerService extends SystemService {
recordTopInsetLocked(display);
}
addDisplayPowerControllerLocked(display);
mDisplayStates.append(displayId, Display.STATE_OFF);
mDisplayStates.append(displayId, Display.STATE_UNKNOWN);
mDisplayBrightnesses.append(displayId, display.getDisplayInfoLocked().brightnessDefault);
DisplayManagerGlobal.invalidateLocalDisplayInfoCaches();
@@ -1204,16 +1204,15 @@ public final class DisplayManagerService extends SystemService {
DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
final LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(device);
final int state;
final int displayId = display.getDisplayIdLocked();
final int state = mDisplayStates.get(displayId);
if (display.isEnabled()) {
state = mDisplayStates.get(displayId);
} else {
state = Display.STATE_OFF;
// Only send a request for display state if the display state has already been
// initialized by DisplayPowercontroller.
if (state != Display.STATE_UNKNOWN) {
final float brightness = mDisplayBrightnesses.get(displayId);
return device.requestDisplayStateLocked(state, brightness);
}
final float brightness = mDisplayBrightnesses.get(displayId);
return device.requestDisplayStateLocked(state, brightness);
}
return null;
}

View File

@@ -982,7 +982,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mWaitingForNegativeProximity = false;
mIgnoreProximityUntilChanged = false;
}
if (mScreenOffBecauseOfProximity) {
if (!mLogicalDisplay.isEnabled() || mScreenOffBecauseOfProximity) {
state = Display.STATE_OFF;
}

View File

@@ -682,7 +682,10 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|| oldState == Display.STATE_ON_SUSPEND) {
setDisplayState(Display.STATE_ON);
currentState = Display.STATE_ON;
} else {
// If UNKNOWN, we still want to set the initial display state,
// otherwise, return early.
} else if (oldState != Display.STATE_UNKNOWN) {
return; // old state and new state is off
}
}