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

Commit 34306c39 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Synchronize and slow down fade in

Use slower animation when turning on the display, and request
a black frame when going to sleep.

Fixes: 137398766
Test: Wake up with presence sensor
Test: Wake up by uncovering prox sensor
Test: Wake up by pressing power (with AOD on or off)
Test: Receive notification from AOD
Change-Id: Ic3201e4c6b9de3d1322c9473897bca21fe63f773
parent b5f152e3
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -50,9 +50,23 @@ public interface DozeHost {
     */
    void onSlpiTap(float x, float y);

    /**
     * Artificially dim down the the display by changing scrim opacities.
     * @param scrimOpacity opacity from 0 to 1.
     */
    default void setAodDimmingScrim(float scrimOpacity) {}

    /**
     * Sets the actual display brightness.
     * @param value from 0 to 255.
     */
    void setDozeScreenBrightness(int value);

    /**
     * Makes scrims black and changes animation durations.
     */
    default void prepareForGentleWakeUp() {}

    void onIgnoreTouchWhilePulsing(boolean ignore);

    /**
+5 −2
Original line number Diff line number Diff line
@@ -82,7 +82,10 @@ public class DozeScreenState implements DozeMachine.Part {
        boolean messagePending = mHandler.hasCallbacks(mApplyPendingScreenState);
        boolean pulseEnding = oldState  == DozeMachine.State.DOZE_PULSE_DONE
                && newState == DozeMachine.State.DOZE_AOD;
        if (messagePending || oldState == DozeMachine.State.INITIALIZED || pulseEnding) {
        boolean turningOn = (oldState == DozeMachine.State.DOZE_AOD_PAUSED
                || oldState  == DozeMachine.State.DOZE) && newState == DozeMachine.State.DOZE_AOD;
        boolean justInitialized = oldState == DozeMachine.State.INITIALIZED;
        if (messagePending || justInitialized || pulseEnding || turningOn) {
            // During initialization, we hide the navigation bar. That is however only applied after
            // a traversal; setting the screen state here is immediate however, so it can happen
            // that the screen turns on again before the navigation bar is hidden. To work around
@@ -91,7 +94,7 @@ public class DozeScreenState implements DozeMachine.Part {

            // Delay screen state transitions even longer while animations are running.
            boolean shouldDelayTransition = newState == DozeMachine.State.DOZE_AOD
                    && mParameters.shouldControlScreenOff();
                    && mParameters.shouldControlScreenOff() && !turningOn;

            if (shouldDelayTransition) {
                mWakeLock.setAcquired(true);
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ public class DozeTriggers implements DozeMachine.Part {
            // Let's prepare the display to wake-up by drawing black.
            // This will cover the hardware wake-up sequence, where the display
            // becomes black for a few frames.
            mDozeHost.setAodDimmingScrim(255f);
            mDozeHost.setAodDimmingScrim(1f);
        }
        mMachine.wakeUp();
    }
+1 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ public class DozeUi implements DozeMachine.Part {
                break;
            case DOZE:
            case DOZE_AOD_PAUSED:
                mHost.prepareForGentleWakeUp();
                unscheduleTimeTick();
                break;
            case DOZE_REQUEST_PULSE:
+14 −0
Original line number Diff line number Diff line
@@ -486,6 +486,20 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        mState.AOD.setAodFrontScrimAlpha(alpha);
    }

    /**
     * Set front scrim to black, cancelling animations, in order to prepare to fade them
     * away once the display turns on.
     */
    public void prepareForGentleWakeUp() {
        if (mState == ScrimState.AOD && mDozeParameters.getAlwaysOn()) {
            mCurrentInFrontAlpha = 1f;
            mAnimateChange = false;
            updateScrims();
            mAnimateChange = true;
            mAnimationDuration = ANIMATION_DURATION_LONG;
        }
    }

    /**
     * If the lock screen sensor is active.
     */
Loading