diff options
| author | 2024-05-16 19:06:30 +0000 | |
|---|---|---|
| committer | 2024-05-16 19:06:30 +0000 | |
| commit | 331608fce24522f1df3eb85038561172f74edabd (patch) | |
| tree | 1e9ed3e547256df3a2ba05da36f538c2db8f92a6 | |
| parent | b1606f58a61e8328200daa13ce658fb47b4fda4a (diff) | |
| parent | e3b610050c8fd8c79dbc2c8eeaabf18e8e9a0864 (diff) | |
Merge changes Ibd29ad17,I13b47198 into main
* changes:
Reset keyguard y translation
Fix scrim transition when leaving DREAMING
5 files changed, 95 insertions, 11 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt index cb2d4e07e3a2..4cb4201704ff 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt @@ -275,6 +275,28 @@ class KeyguardInteractorTest : SysuiTestCase() { } @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 { val keyguardTranslationY by collectLastValue(underTest.keyguardTranslationY) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 8065c0f4bc41..c44a40f33857 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -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 @@ -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") @@ -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 @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 5b0b46ed18d2..d3d2b1ebcb88 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -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)) { @@ -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(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt index ef15d21107b0..1e786073b623 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt @@ -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) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index b9312d3ce2be..320b6ffff433 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -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; @@ -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; @@ -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, @@ -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); @@ -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 @@ -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); |