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

Commit a18705b2 authored by Yifei Zhang's avatar Yifei Zhang Committed by Android (Google) Code Review
Browse files

Merge "dpc: fix DisplayPowerControllerTest for cancelBlockScreenOn" into main

parents a8fdd28e 50a25de3
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2098,7 +2098,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    private void onDisplayOffloadUnblockScreenOn(DisplayOffloadSession displayOffloadSession) {
        Message msg = mHandler.obtainMessage(MSG_OFFLOADING_SCREEN_ON_UNBLOCKED,
                displayOffloadSession);
        mHandler.sendMessage(msg);
        mHandler.sendMessageAtTime(msg, mClock.uptimeMillis());
    }

    private void unblockScreenOnByDisplayOffload() {
@@ -2116,7 +2116,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        if (mDisplayOffloadSession == null) {
            return;
        }
        if (mPendingScreenOnUnblockerByDisplayOffload != null) {
        if (mPendingScreenOnUnblockerByDisplayOffload == null) {
            // Already unblocked.
            return;
        }
@@ -2134,7 +2134,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call

        // If the screen is turning on, give displayoffload a chance to do something before the
        // screen actually turns on.
        // TODO(b/316941732): add tests for this displayoffload screen-on blocker.
        if (isOn && changed && !mScreenTurningOnWasBlockedByDisplayOffload) {
            blockScreenOnByDisplayOffload(mDisplayOffloadSession);
        } else if (!isOn && mScreenTurningOnWasBlockedByDisplayOffload) {
+3 −3
Original line number Diff line number Diff line
@@ -1707,7 +1707,8 @@ public final class DisplayPowerControllerTest {
        int initState = Display.STATE_OFF;
        mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID);
        mHolder.dpc.setDisplayOffloadSession(mDisplayOffloadSession);
        when(mDisplayOffloadSession.blockScreenOn(any())).thenReturn(true);
        ArgumentCaptor<Runnable> argumentCaptor = ArgumentCaptor.forClass(Runnable.class);
        when(mDisplayOffloadSession.blockScreenOn(argumentCaptor.capture())).thenReturn(true);

        // Start with OFF.
        when(mHolder.displayPowerState.getScreenState()).thenReturn(initState);
@@ -1721,8 +1722,7 @@ public final class DisplayPowerControllerTest {
        mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
        advanceTime(1); // Run updatePowerState

        ArgumentCaptor<Runnable> argumentCaptor = ArgumentCaptor.forClass(Runnable.class);
        verify(mDisplayOffloadSession).blockScreenOn(argumentCaptor.capture());
        verify(mDisplayOffloadSession).blockScreenOn(any());

        // Unblocked
        argumentCaptor.getValue().run();