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

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

Merge "Don't check Doze state if device is in the middle of a transition" into main

parents 4fd1dfba 9098b14c
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -276,6 +276,23 @@ public class DozeSuppressorTest extends SysuiTestCase {
        verify(mDozeMachine).requestState(DOZE_AOD);
    }


    @Test
    public void testPowerSaveChanged_notActive_dozeMachineStateNull() {
        // GIVEN DOZE (not showing aod content)
        when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(true);
        mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED);
        when(mDozeMachine.getState()).thenReturn(null);
        captureDozeHostCallback();

        // WHEN power save mode is no longer active
        when(mDozeHost.isPowerSaveActive()).thenReturn(false);
        mDozeHostCallback.onPowerSaveChanged(false);

        // THEN the state doesn't change
        verify(mDozeMachine, never()).requestState(DOZE_AOD);
    }

    @Test
    public void testAlwaysOnSuppressedChanged_nowSuppressed() {
        // GIVEN DOZE_AOD
+7 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWA
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING;

import android.annotation.MainThread;
import android.annotation.Nullable;
import android.content.res.Configuration;
import android.hardware.display.AmbientDisplayConfiguration;
import android.util.Log;
@@ -259,16 +260,16 @@ public class DozeMachine {
    }

    /**
     * @return the current state.
     *
     * This must not be called during a transition.
     * @return the current state. Returns null if the DozeMachine is currently executing a
     * transition.
     */
    @MainThread
    public State getState() {
    public @Nullable State getState() {
        Assert.isMainThread();
        if (isExecutingTransition()) {
            throw new IllegalStateException("Cannot get state because there were pending "
            Log.w(TAG, "Returning null for DozeMachine.getState because there were pending"
                    + " transitions: " + mQueuedRequests);
            return null;
        }
        return mState;
    }
+6 −5
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ public class DozeTriggers implements DozeMachine.Part {

        if (isWakeOnPresence) {
            onWakeScreen(isWakeDisplayEvent,
                    mMachine.isExecutingTransition() ? null : mMachine.getState(),
                    mMachine.getState(),
                    pulseReason);
        } else if (isLongPress) {
            requestPulse(pulseReason, true /* alreadyPerformedProxCheck */,
@@ -572,9 +572,7 @@ public class DozeTriggers implements DozeMachine.Part {
        Assert.isMainThread();
        mDozeHost.extendPulse(reason);

        // we can't determine the dozing state if we're currently transitioning
        final DozeMachine.State dozeState =
                mMachine.isExecutingTransition() ? null : mMachine.getState();
        final DozeMachine.State dozeState = mMachine.getState();

        // When already pulsing we're allowed to show the wallpaper directly without
        // requesting a new pulse.
@@ -638,7 +636,10 @@ public class DozeTriggers implements DozeMachine.Part {
                .ifPresent(uiEventEnum -> mUiEventLogger.log(uiEventEnum, getKeyguardSessionId()));
    }

    private boolean canPulse(DozeMachine.State dozeState, boolean pulsePerformedProximityCheck) {
    private boolean canPulse(
            @Nullable DozeMachine.State dozeState,
            boolean pulsePerformedProximityCheck
    ) {
        final boolean dozePausedOrPausing = dozeState == State.DOZE_AOD_PAUSED
                || dozeState == State.DOZE_AOD_PAUSING;
        return dozeState == DozeMachine.State.DOZE
+16 −9
Original line number Diff line number Diff line
@@ -438,15 +438,29 @@ public class DozeTriggersTest extends SysuiTestCase {
    }

    @Test
    public void testIsExecutingTransition_dropPulse() {
    public void nullState_dropUdfpsLongPressPulse() {
        when(mHost.isPulsePending()).thenReturn(false);
        when(mMachine.isExecutingTransition()).thenReturn(true);
        when(mMachine.getState()).thenReturn(null);

        mTriggers.onSensor(DozeLog.PULSE_REASON_SENSOR_LONG_PRESS, 100, 100, null);

        verify(mDozeLog).tracePulseDropped(anyString(), eq(null));
    }

    @Test
    public void testIsExecutingTransition_dropPulseForUdfpsLongPress() {
        when(mHost.isPulsePending()).thenReturn(false);
        when(mMachine.isExecutingTransition()).thenReturn(true);

        mTriggers.onSensor(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, 100, 100, null);

        // THEN pulse is dropped
        verify(mDozeLog).tracePulseDropped(anyString(), eq(null));

        // THEN aod interrupt is not sent
        verify(mAuthController, never()).onAodInterrupt(anyInt(), anyInt(), anyFloat(), anyFloat());
    }

    @Test
    public void udfpsLongPress_triggeredWhenAodPaused() {
        // GIVEN device is DOZE_AOD_PAUSED
@@ -505,13 +519,6 @@ public class DozeTriggersTest extends SysuiTestCase {
        verify(mAuthController, never()).onAodInterrupt(anyInt(), anyInt(), anyFloat(), anyFloat());
    }

    @Test
    public void udfpsLongPress_dozeState_notRegistered() {
        // GIVEN device is DOZE_AOD_PAUSED
        when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
        // beverlyt
    }

    @Test
    @EnableFlags({
            android.hardware.biometrics.Flags.FLAG_SCREEN_OFF_UNLOCK_UDFPS,