Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33b90a36 authored by Santos Cordon's avatar Santos Cordon
Browse files

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
parent 85399be2
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -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,17 +1204,16 @@ 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);
            }
        }
        return null;
    }

+2 −1
Original line number Diff line number Diff line
@@ -982,7 +982,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            mWaitingForNegativeProximity = false;
            mIgnoreProximityUntilChanged = false;
        }
        if (mScreenOffBecauseOfProximity) {

        if (!mLogicalDisplay.isEnabled() || mScreenOffBecauseOfProximity) {
            state = Display.STATE_OFF;
        }

+4 −1
Original line number Diff line number Diff line
@@ -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
                            }
                        }