Loading packages/SystemUI/multivalentTests/src/com/android/systemui/doze/DozeSuppressorTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +7 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java +6 −5 Original line number Diff line number Diff line Loading @@ -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 */, Loading Loading @@ -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. Loading Loading @@ -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 Loading packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java +16 −9 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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, Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/doze/DozeSuppressorTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +7 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading
packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java +6 −5 Original line number Diff line number Diff line Loading @@ -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 */, Loading Loading @@ -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. Loading Loading @@ -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 Loading
packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java +16 −9 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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, Loading