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

Commit af78b698 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Tweak DisplayPowerController#animateScreenStateChange() for AoF" into main

parents 8b7b1cae 958fbbbd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2347,6 +2347,14 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            mPendingScreenOff = false;
        }

        if (mFlags.isEnsureColorFadeWhenTurningOnEnabled()
                && ((mPowerState.getScreenState() == Display.STATE_OFF)
                && target != Display.STATE_OFF)) {
            // ensure ColorFade is present.
            mPowerState.prepareColorFade(mContext,
                    mColorFadeFadesConfig ? ColorFade.MODE_FADE : ColorFade.MODE_WARM_UP);
        }

        if (mDisplayBlanksAfterDozeConfig
                && Display.isDozeState(mPowerState.getScreenState())
                && !Display.isDozeState(target)) {
+12 −0
Original line number Diff line number Diff line
@@ -309,6 +309,10 @@ public class DisplayManagerFlags {
            Flags.FLAG_MODE_SWITCH_WITHOUT_SAVING,
            Flags::modeSwitchWithoutSaving
    );
    private final FlagState mEnsureColorFadeWhenTurningOn = new FlagState(
            Flags.FLAG_ENSURE_COLOR_FADE_WHEN_TURNING_ON,
            Flags::ensureColorFadeWhenTurningOn
    );

    /**
     * @return {@code true} if 'port' is allowed in display layout configuration file.
@@ -651,6 +655,13 @@ public class DisplayManagerFlags {
        return mModeSwitchWithoutSaving.isEnabled();
    }

    /**
     * @return {@code true} if the flag for ensure color fad when turning screen on is enabled
     */
    public boolean isEnsureColorFadeWhenTurningOnEnabled() {
        return mEnsureColorFadeWhenTurningOn.isEnabled();
    }

    /**
     * dumps all flagstates
     * @param pw printWriter
@@ -714,6 +725,7 @@ public class DisplayManagerFlags {
        pw.println(" " + mDispatchDisplayModeWithVsyncOffsets);
        pw.println(" " + mEnableDefaultDisplayInTopologySwitch);
        pw.println(" " + mModeSwitchWithoutSaving);
        pw.println(" " + mEnsureColorFadeWhenTurningOn);
    }

    private static class FlagState {
+11 −0
Original line number Diff line number Diff line
@@ -556,3 +556,14 @@ flag {
    bug: "253296253"
    is_fixed_read_only: true
}

flag {
    name: "ensure_color_fade_when_turning_on"
    namespace: "biometrics_integration"
    description: "Ensure color fade when turing on screen"
    bug: "384986206"
    is_fixed_read_only: true
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -2511,6 +2511,25 @@ public final class DisplayPowerControllerTest {
        // No crash = success
    }

    @Test
    public void testScreenOff_thenTurnOn_ensureColorFade() {
        mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID);

        // Ensure the feature flag is enabled.
        when(mDisplayManagerFlagsMock.isEnsureColorFadeWhenTurningOnEnabled()).thenReturn(true);
        // Ensure the initial screen state is OFF.
        when(mHolder.displayPowerState.getScreenState()).thenReturn(Display.STATE_OFF);

        // Run the DPC logic.
        DisplayPowerRequest dpr = new DisplayPowerRequest();
        dpr.policy = DisplayPowerRequest.POLICY_BRIGHT;
        mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
        advanceTime(1); // Run updatePowerState

        // The conditions are met, so prepareColorFade() is invoked.
        verify(mHolder.displayPowerState).prepareColorFade(any(), anyInt());
    }

    /**
     * Creates a mock and registers it to {@link LocalServices}.
     */