diff options
| author | 2024-03-20 10:32:27 -0400 | |
|---|---|---|
| committer | 2024-03-20 16:14:51 -0400 | |
| commit | ae90088ebc97ad609d1b278fcfcd78b75340e2c0 (patch) | |
| tree | 4403a5129d8a9677de81d6dac6d22dca9eaf192e | |
| parent | db6f702b46e5d735548ba71eebecdec627c07bb9 (diff) | |
Keep notifications hidden when dreaming
This avoids notifications flickering when tapping to exit the dream,
before the glanceable hub is shown. This is due to a race condition
between the unocclusion logic running which sets StatusBarState back to
KEYGUARD, and the transition from DREAMING->HUB running.
Fixes: 329091482
Flag: ACONFIG com.android.systemui.communal_hub TEAMFOOD
Test: atest SharedNotificationContainerViewModelTest
Change-Id: Ib96c06eeba630c35f048ca1c8479f349f922d11b
3 files changed, 34 insertions, 8 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index 5256bb956bc4..f969ee677763 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -290,10 +290,15 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { testScope.runTest { val alpha by collectLastValue(underTest.glanceableHubAlpha) - // Start on dream - showDream() + // Start on lockscreen, notifications should be unhidden. + showLockscreen() assertThat(alpha).isEqualTo(1f) + // Transition to dream, notifications should be hidden so that transition + // from dream->hub doesn't cause notification flicker. + showDream() + assertThat(alpha).isEqualTo(0f) + // Start transitioning to glanceable hub val progress = 0.6f keyguardTransitionRepository.sendTransitionStep( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt index 6db6719c76c7..962897e9c4db 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt @@ -20,6 +20,7 @@ import android.view.View import android.view.WindowInsets import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle +import com.android.systemui.Flags.communalHub import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.ui.viewmodel.BurnInParameters @@ -149,9 +150,11 @@ constructor( } } - launch { - viewModel.glanceableHubAlpha.collect { - controller.setMaxAlphaForGlanceableHub(it) + if (communalHub()) { + launch { + viewModel.glanceableHubAlpha.collect { + controller.setMaxAlphaForGlanceableHub(it) + } } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt index 6d0b8734394f..04c115d9e34c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt @@ -29,6 +29,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.KeyguardState.ALTERNATE_BOUNCER import com.android.systemui.keyguard.shared.model.KeyguardState.AOD import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING +import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING import com.android.systemui.keyguard.shared.model.KeyguardState.GLANCEABLE_HUB import com.android.systemui.keyguard.shared.model.KeyguardState.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN @@ -241,7 +242,22 @@ constructor( started = SharingStarted.Eagerly, initialValue = false, ) - .dumpWhileCollecting("isOnGlanceableHubWithoutShade") + .dumpValue("isOnGlanceableHubWithoutShade") + + /** Are we on the dream without the shade/qs? */ + private val isDreamingWithoutShade: Flow<Boolean> = + combine( + keyguardTransitionInteractor.isFinishedInState(DREAMING), + isAnyExpanded, + ) { isDreaming, isAnyExpanded -> + isDreaming && !isAnyExpanded + } + .stateIn( + scope = applicationScope, + started = SharingStarted.Eagerly, + initialValue = false, + ) + .dumpValue("isDreamingWithoutShade") /** * Fade in if the user swipes the shade back up, not if collapsed by going to AOD. This is @@ -459,6 +475,7 @@ constructor( combineTransform( isOnGlanceableHubWithoutShade, isOnLockscreen, + isDreamingWithoutShade, merge( lockscreenToGlanceableHubTransitionViewModel.notificationAlpha, glanceableHubToLockscreenTransitionViewModel.notificationAlpha, @@ -466,9 +483,9 @@ constructor( // Manually emit on start because [notificationAlpha] only starts emitting // when transitions start. .onStart { emit(1f) } - ) { isOnGlanceableHubWithoutShade, isOnLockscreen, alpha, + ) { isOnGlanceableHubWithoutShade, isOnLockscreen, isDreamingWithoutShade, alpha, -> - if (isOnGlanceableHubWithoutShade && !isOnLockscreen) { + if ((isOnGlanceableHubWithoutShade || isDreamingWithoutShade) && !isOnLockscreen) { // Notifications should not be visible on the glanceable hub. // TODO(b/321075734): implement a way to actually set the notifications to // gone while on the hub instead of just adjusting alpha @@ -483,6 +500,7 @@ constructor( emit(1f) } } + .distinctUntilChanged() .dumpWhileCollecting("glanceableHubAlpha") /** |