Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt +22 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,28 @@ class KeyguardInteractorTest : SysuiTestCase() { assertThat(keyguardTranslationY).isEqualTo(0f) } @Test fun keyguardTranslationY_whenNotGoneAndShadeIsReesetEmitsZero() = testScope.runTest { val keyguardTranslationY by collectLastValue(underTest.keyguardTranslationY) configRepository.setDimensionPixelSize( R.dimen.keyguard_translate_distance_on_swipe_up, 100 ) configRepository.onAnyConfigurationChange() shadeRepository.setLegacyShadeExpansion(1f) keyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.AOD, to = KeyguardState.LOCKSCREEN, testScope, ) assertThat(keyguardTranslationY).isEqualTo(0f) } @Test fun keyguardTranslationY_whenTransitioningToGoneAndShadeIsExpandingEmitsNonZero() = testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +23 −4 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import javax.inject.Provider import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted Loading Loading @@ -181,7 +182,11 @@ constructor( } .sample(powerInteractor.isAwake) { isAbleToDream, isAwake -> isAbleToDream && isAwake } .debounce(50L) .distinctUntilChanged() .stateIn( scope = applicationScope, started = SharingStarted.WhileSubscribed(), initialValue = false, ) /** Whether the keyguard is showing or not. */ @Deprecated("Use KeyguardTransitionInteractor + KeyguardState") Loading Loading @@ -225,7 +230,19 @@ constructor( @JvmField val primaryBouncerShowing: Flow<Boolean> = bouncerRepository.primaryBouncerShow /** Whether the alternate bouncer is showing or not. */ val alternateBouncerShowing: Flow<Boolean> = bouncerRepository.alternateBouncerVisible val alternateBouncerShowing: Flow<Boolean> = bouncerRepository.alternateBouncerVisible.sample(isAbleToDream) { alternateBouncerVisible, isAbleToDream -> if (isAbleToDream) { // If the alternate bouncer will show over a dream, it is likely that the dream has // requested a dismissal, which will stop the dream. By delaying this slightly, the // DREAMING->LOCKSCREEN transition will now happen first, followed by // LOCKSCREEN->ALTERNATE_BOUNCER. delay(600L) } alternateBouncerVisible } /** Observable for the [StatusBarState] */ val statusBarState: Flow<StatusBarState> = repository.statusBarState Loading Loading @@ -301,10 +318,12 @@ constructor( shadeRepository.legacyShadeExpansion.onStart { emit(0f) }, keyguardTransitionInteractor.transitionValue(GONE).onStart { emit(0f) }, ) { legacyShadeExpansion, goneValue -> if (goneValue == 1f || (goneValue == 0f && legacyShadeExpansion == 0f)) { val isLegacyShadeInResetPosition = legacyShadeExpansion == 0f || legacyShadeExpansion == 1f if (goneValue == 1f || (goneValue == 0f && isLegacyShadeInResetPosition)) { // Reset the translation value emit(0f) } else if (legacyShadeExpansion > 0f && legacyShadeExpansion < 1f) { } else if (!isLegacyShadeInResetPosition) { // On swipe up, translate the keyguard to reveal the bouncer, OR a GONE // transition is running, which means this is a swipe to dismiss. Values of // 0f and 1f need to be ignored in the legacy shade expansion. These can Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +10 −2 Original line number Diff line number Diff line Loading @@ -2805,7 +2805,16 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mScrimController.setExpansionAffectsAlpha(!unlocking); if (mAlternateBouncerInteractor.isVisibleState()) { if (!DeviceEntryUdfpsRefactor.isEnabled()) { if (DeviceEntryUdfpsRefactor.isEnabled()) { if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded()) && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED || mTransitionToFullShadeProgress > 0f)) { // Assume scrim state for shade is already correct and do nothing } else { // Safeguard which prevents the scrim from being stuck in the wrong state mScrimController.transitionTo(ScrimState.KEYGUARD); } } else { if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded()) && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED || mTransitionToFullShadeProgress > 0f)) { Loading @@ -2814,7 +2823,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED); } } // This will cancel the keyguardFadingAway animation if it is running. We need to do // this as otherwise it can remain pending and leave keyguard in a weird state. mUnlockScrimCallback.onCancelled(); Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -633,7 +633,7 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest // GIVEN a prior transition has run to DREAMING keyguardRepository.setDreamingWithOverlay(true) runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.DREAMING) runCurrent() advanceTimeBy(60L) // WHEN the device wakes up without a keyguard keyguardRepository.setKeyguardShowing(false) Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +39 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; import static android.provider.Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED; import static android.provider.Settings.Global.HEADS_UP_ON; import static com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR; import static com.android.systemui.Flags.FLAG_KEYBOARD_SHORTCUT_HELPER_REWRITE; import static com.android.systemui.Flags.FLAG_LIGHT_REVEAL_MIGRATION; import static com.android.systemui.flags.Flags.SHORTCUT_LIST_SEARCH_LAYOUT; Loading Loading @@ -70,6 +71,8 @@ import android.os.IThermalService; import android.os.Looper; import android.os.PowerManager; import android.os.UserHandle; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.service.dreams.IDreamManager; import android.support.test.metricshelper.MetricsAsserts; import android.testing.AndroidTestingRunner; Loading Loading @@ -366,9 +369,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { // Turn AOD on and toggle feature flag for jank fixes mFeatureFlags.set(Flags.ZJ_285570694_LOCKSCREEN_TRANSITION_FROM_AOD, true); when(mDozeParameters.getAlwaysOn()).thenReturn(true); if (!SceneContainerFlag.isEnabled()) { mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR); } IThermalService thermalService = mock(IThermalService.class); mPowerManager = new PowerManager(mContext, mPowerManagerService, thermalService, Loading Loading @@ -837,6 +837,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { } @Test @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testSetDozingNotUnlocking_transitionToAuthScrimmed_cancelKeyguardFadingAway() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); when(mKeyguardStateController.isKeyguardFadingAway()).thenReturn(true); Loading @@ -848,7 +849,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase { } @Test public void testOccludingQSNotExpanded_transitionToAuthScrimmed() { @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testOccludingQSNotExpanded_flagOff_transitionToAuthScrimmed() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // GIVEN device occluded and panel is NOT expanded Loading @@ -862,6 +864,39 @@ public class CentralSurfacesImplTest extends SysuiTestCase { } @Test @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testNotOccluding_QSNotExpanded_flagOn_doesNotTransitionScrimState() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // GIVEN device occluded and panel is NOT expanded mCentralSurfaces.setBarStateForTest(SHADE); when(mKeyguardStateController.isOccluded()).thenReturn(false); when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(false); mCentralSurfaces.updateScrimController(); // Tests the safeguard to reset the scrimstate verify(mScrimController, never()).transitionTo(any()); } @Test @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testNotOccluding_QSExpanded_flagOn_doesTransitionScrimStateToKeyguard() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // GIVEN device occluded and panel is NOT expanded mCentralSurfaces.setBarStateForTest(SHADE); when(mKeyguardStateController.isOccluded()).thenReturn(false); when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true); mCentralSurfaces.updateScrimController(); // Tests the safeguard to reset the scrimstate verify(mScrimController, never()).transitionTo(eq(ScrimState.KEYGUARD)); } @Test @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testOccludingQSExpanded_transitionToAuthScrimmedShade() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt +22 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,28 @@ class KeyguardInteractorTest : SysuiTestCase() { assertThat(keyguardTranslationY).isEqualTo(0f) } @Test fun keyguardTranslationY_whenNotGoneAndShadeIsReesetEmitsZero() = testScope.runTest { val keyguardTranslationY by collectLastValue(underTest.keyguardTranslationY) configRepository.setDimensionPixelSize( R.dimen.keyguard_translate_distance_on_swipe_up, 100 ) configRepository.onAnyConfigurationChange() shadeRepository.setLegacyShadeExpansion(1f) keyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.AOD, to = KeyguardState.LOCKSCREEN, testScope, ) assertThat(keyguardTranslationY).isEqualTo(0f) } @Test fun keyguardTranslationY_whenTransitioningToGoneAndShadeIsExpandingEmitsNonZero() = testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +23 −4 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import javax.inject.Provider import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted Loading Loading @@ -181,7 +182,11 @@ constructor( } .sample(powerInteractor.isAwake) { isAbleToDream, isAwake -> isAbleToDream && isAwake } .debounce(50L) .distinctUntilChanged() .stateIn( scope = applicationScope, started = SharingStarted.WhileSubscribed(), initialValue = false, ) /** Whether the keyguard is showing or not. */ @Deprecated("Use KeyguardTransitionInteractor + KeyguardState") Loading Loading @@ -225,7 +230,19 @@ constructor( @JvmField val primaryBouncerShowing: Flow<Boolean> = bouncerRepository.primaryBouncerShow /** Whether the alternate bouncer is showing or not. */ val alternateBouncerShowing: Flow<Boolean> = bouncerRepository.alternateBouncerVisible val alternateBouncerShowing: Flow<Boolean> = bouncerRepository.alternateBouncerVisible.sample(isAbleToDream) { alternateBouncerVisible, isAbleToDream -> if (isAbleToDream) { // If the alternate bouncer will show over a dream, it is likely that the dream has // requested a dismissal, which will stop the dream. By delaying this slightly, the // DREAMING->LOCKSCREEN transition will now happen first, followed by // LOCKSCREEN->ALTERNATE_BOUNCER. delay(600L) } alternateBouncerVisible } /** Observable for the [StatusBarState] */ val statusBarState: Flow<StatusBarState> = repository.statusBarState Loading Loading @@ -301,10 +318,12 @@ constructor( shadeRepository.legacyShadeExpansion.onStart { emit(0f) }, keyguardTransitionInteractor.transitionValue(GONE).onStart { emit(0f) }, ) { legacyShadeExpansion, goneValue -> if (goneValue == 1f || (goneValue == 0f && legacyShadeExpansion == 0f)) { val isLegacyShadeInResetPosition = legacyShadeExpansion == 0f || legacyShadeExpansion == 1f if (goneValue == 1f || (goneValue == 0f && isLegacyShadeInResetPosition)) { // Reset the translation value emit(0f) } else if (legacyShadeExpansion > 0f && legacyShadeExpansion < 1f) { } else if (!isLegacyShadeInResetPosition) { // On swipe up, translate the keyguard to reveal the bouncer, OR a GONE // transition is running, which means this is a swipe to dismiss. Values of // 0f and 1f need to be ignored in the legacy shade expansion. These can Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +10 −2 Original line number Diff line number Diff line Loading @@ -2805,7 +2805,16 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mScrimController.setExpansionAffectsAlpha(!unlocking); if (mAlternateBouncerInteractor.isVisibleState()) { if (!DeviceEntryUdfpsRefactor.isEnabled()) { if (DeviceEntryUdfpsRefactor.isEnabled()) { if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded()) && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED || mTransitionToFullShadeProgress > 0f)) { // Assume scrim state for shade is already correct and do nothing } else { // Safeguard which prevents the scrim from being stuck in the wrong state mScrimController.transitionTo(ScrimState.KEYGUARD); } } else { if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded()) && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED || mTransitionToFullShadeProgress > 0f)) { Loading @@ -2814,7 +2823,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED); } } // This will cancel the keyguardFadingAway animation if it is running. We need to do // this as otherwise it can remain pending and leave keyguard in a weird state. mUnlockScrimCallback.onCancelled(); Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -633,7 +633,7 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest // GIVEN a prior transition has run to DREAMING keyguardRepository.setDreamingWithOverlay(true) runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.DREAMING) runCurrent() advanceTimeBy(60L) // WHEN the device wakes up without a keyguard keyguardRepository.setKeyguardShowing(false) Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +39 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; import static android.provider.Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED; import static android.provider.Settings.Global.HEADS_UP_ON; import static com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR; import static com.android.systemui.Flags.FLAG_KEYBOARD_SHORTCUT_HELPER_REWRITE; import static com.android.systemui.Flags.FLAG_LIGHT_REVEAL_MIGRATION; import static com.android.systemui.flags.Flags.SHORTCUT_LIST_SEARCH_LAYOUT; Loading Loading @@ -70,6 +71,8 @@ import android.os.IThermalService; import android.os.Looper; import android.os.PowerManager; import android.os.UserHandle; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.service.dreams.IDreamManager; import android.support.test.metricshelper.MetricsAsserts; import android.testing.AndroidTestingRunner; Loading Loading @@ -366,9 +369,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { // Turn AOD on and toggle feature flag for jank fixes mFeatureFlags.set(Flags.ZJ_285570694_LOCKSCREEN_TRANSITION_FROM_AOD, true); when(mDozeParameters.getAlwaysOn()).thenReturn(true); if (!SceneContainerFlag.isEnabled()) { mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR); } IThermalService thermalService = mock(IThermalService.class); mPowerManager = new PowerManager(mContext, mPowerManagerService, thermalService, Loading Loading @@ -837,6 +837,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { } @Test @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testSetDozingNotUnlocking_transitionToAuthScrimmed_cancelKeyguardFadingAway() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); when(mKeyguardStateController.isKeyguardFadingAway()).thenReturn(true); Loading @@ -848,7 +849,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase { } @Test public void testOccludingQSNotExpanded_transitionToAuthScrimmed() { @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testOccludingQSNotExpanded_flagOff_transitionToAuthScrimmed() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // GIVEN device occluded and panel is NOT expanded Loading @@ -862,6 +864,39 @@ public class CentralSurfacesImplTest extends SysuiTestCase { } @Test @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testNotOccluding_QSNotExpanded_flagOn_doesNotTransitionScrimState() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // GIVEN device occluded and panel is NOT expanded mCentralSurfaces.setBarStateForTest(SHADE); when(mKeyguardStateController.isOccluded()).thenReturn(false); when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(false); mCentralSurfaces.updateScrimController(); // Tests the safeguard to reset the scrimstate verify(mScrimController, never()).transitionTo(any()); } @Test @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testNotOccluding_QSExpanded_flagOn_doesTransitionScrimStateToKeyguard() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // GIVEN device occluded and panel is NOT expanded mCentralSurfaces.setBarStateForTest(SHADE); when(mKeyguardStateController.isOccluded()).thenReturn(false); when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true); mCentralSurfaces.updateScrimController(); // Tests the safeguard to reset the scrimstate verify(mScrimController, never()).transitionTo(eq(ScrimState.KEYGUARD)); } @Test @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) public void testOccludingQSExpanded_transitionToAuthScrimmedShade() { when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); Loading