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

Commit 5f00fa50 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Wake up wallpaper even if there's a notification

Isolated a bright pulse from a regular pulse (dark wallpaper)
and created a new machine state for the new case.

The state is also propagated to ScrimController, in order to
understand if the wallpaper should be dimmed down or not.

Fixes: 123991469
Test: receive notification, trigger sensor
Test: other manual notification tests
Test: repeat with image wallpaper and live wallpaper
Test: atest ScrimControllerTest
Test: atest DozeWallpaperStateTest
Change-Id: I6b54615dd6c7ecadf7dffd2d61ae7f93390d4c97
parent 68d476c7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -87,7 +87,8 @@ public class DozeDockHandler implements DozeMachine.Part {
    }

    private void requestPulseOutNow(State dozeState) {
        if (dozeState == State.DOZE_REQUEST_PULSE || dozeState == State.DOZE_PULSING) {
        if (dozeState == State.DOZE_REQUEST_PULSE || dozeState == State.DOZE_PULSING
                || dozeState == State.DOZE_PULSING_BRIGHT) {
            final int pulseReason = mMachine.getPulseReason();
            if (pulseReason == DozeLog.PULSE_REASON_DOCKING) {
                mDozeHost.stopPulsing();
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class DozeFactory {
                new DozeScreenState(wrappedService, handler, params, wakeLock),
                createDozeScreenBrightness(context, wrappedService, sensorManager, host, params,
                        handler),
                new DozeWallpaperState(context, machine),
                new DozeWallpaperState(context),
                new DozeDockHandler(context, machine, host, config, handler, dockManager)
        });

+5 −1
Original line number Diff line number Diff line
@@ -33,7 +33,11 @@ public interface DozeHost {
    boolean isProvisioned();
    boolean isBlockingDoze();

    void extendPulse();
    /**
     * Makes a current pulse last for twice as long.
     * @param reason why we're extending it.
     */
    void extendPulse(int reason);

    void setAnimateWakeup(boolean animateWakeup);
    void setAnimateScreenOff(boolean animateScreenOff);
+7 −1
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ public class DozeMachine {
        DOZE_REQUEST_PULSE,
        /** Pulse is showing. Device is awake and showing UI. */
        DOZE_PULSING,
        /** Pulse is showing with bright wallpaper. Device is awake and showing UI. */
        DOZE_PULSING_BRIGHT,
        /** Pulse is done showing. Followed by transition to DOZE or DOZE_AOD. */
        DOZE_PULSE_DONE,
        /** Doze is done. DozeService is finished. */
@@ -84,6 +86,7 @@ public class DozeMachine {
            switch (this) {
                case DOZE_REQUEST_PULSE:
                case DOZE_PULSING:
                case DOZE_PULSING_BRIGHT:
                    return true;
                default:
                    return false;
@@ -101,6 +104,7 @@ public class DozeMachine {
                case DOZE:
                    return Display.STATE_OFF;
                case DOZE_PULSING:
                case DOZE_PULSING_BRIGHT:
                    return Display.STATE_ON;
                case DOZE_AOD:
                case DOZE_AOD_PAUSING:
@@ -202,6 +206,7 @@ public class DozeMachine {
        Assert.isMainThread();
        Preconditions.checkState(mState == State.DOZE_REQUEST_PULSE
                || mState == State.DOZE_PULSING
                || mState == State.DOZE_PULSING_BRIGHT
                || mState == State.DOZE_PULSE_DONE, "must be in pulsing state, but is " + mState);
        return mPulseReason;
    }
@@ -283,7 +288,8 @@ public class DozeMachine {
                    break;
                case DOZE_PULSE_DONE:
                    Preconditions.checkState(
                            mState == State.DOZE_REQUEST_PULSE || mState == State.DOZE_PULSING);
                            mState == State.DOZE_REQUEST_PULSE || mState == State.DOZE_PULSING
                                    || mState == State.DOZE_PULSING_BRIGHT);
                    break;
                default:
                    break;
+14 −3
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ public class DozeTriggers implements DozeMachine.Part {
                } else if (isPickup) {
                    gentleWakeUp(pulseReason);
                } else {
                    mDozeHost.extendPulse();
                    mDozeHost.extendPulse(pulseReason);
                }
            }, sensorPerformedProxCheck
                    || (mDockManager != null && mDockManager.isDocked()), pulseReason);
@@ -212,7 +212,8 @@ public class DozeTriggers implements DozeMachine.Part {
        final boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING);
        final boolean aod = (state == DozeMachine.State.DOZE_AOD);

        if (state == DozeMachine.State.DOZE_PULSING) {
        if (state == DozeMachine.State.DOZE_PULSING
                || state == DozeMachine.State.DOZE_PULSING_BRIGHT) {
            boolean ignoreTouch = near;
            if (DEBUG) Log.i(TAG, "Prox changed, ignore touch = " + ignoreTouch);
            mDozeHost.onIgnoreTouchWhilePulsing(ignoreTouch);
@@ -276,6 +277,7 @@ public class DozeTriggers implements DozeMachine.Part {
                mDozeSensors.setListening(false);
                break;
            case DOZE_PULSING:
            case DOZE_PULSING_BRIGHT:
                mDozeSensors.setTouchscreenSensorsListening(false);
                mDozeSensors.setProxListening(true);
                break;
@@ -306,7 +308,16 @@ public class DozeTriggers implements DozeMachine.Part {

    private void requestPulse(final int reason, boolean performedProxCheck) {
        Assert.isMainThread();
        mDozeHost.extendPulse();
        mDozeHost.extendPulse(reason);

        // When already pulsing we're allowed to show the wallpaper directly without
        // requesting a new pulse.
        if (mMachine.getState() == DozeMachine.State.DOZE_PULSING
                && reason == DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN) {
            mMachine.requestState(DozeMachine.State.DOZE_PULSING_BRIGHT);
            return;
        }

        if (mPulsePending || !mAllowPulseTriggers || !canPulse()) {
            if (mAllowPulseTriggers) {
                DozeLog.tracePulseDropped(mContext, mPulsePending, mMachine.getState(),
Loading