diff options
| author | 2024-09-04 13:42:07 +0000 | |
|---|---|---|
| committer | 2024-09-05 09:39:53 +0000 | |
| commit | 52917fc9d93b433e70ea121a7625531939e55b3c (patch) | |
| tree | debdf63f6cf869fa8598c5e36a7aad04e93c68d4 | |
| parent | a5e9826e42353e08463394114a826b16f6b533be (diff) | |
[bc25] Make Lockscreen notifications content-key agnostic.
In the shade scenes implementation, we had to hide notifications on the
lockscreen when the notifications shade is open, in order to prevent a
double-composition of the same ElementKey in the same scene
(notifications in the shade and in the lockscreen, both of which were
rendered by the NotificationsShadeScene composable). With STL overlays,
this is no longer needed.
Bug: 356596436
Flag: com.android.systemui.scene_container
Flag: com.android.systemui.dual_shade
Test: Updated unit tests.
Test: Existing unit tests still pass.
Change-Id: I39bc95cd7fcda70b0e7ea36c59a714d4bf33fef0
3 files changed, 7 insertions, 53 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt index 3e73057ba09b..8d5189eb34e9 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt @@ -73,9 +73,7 @@ constructor( val isShadeLayoutWide by viewModel.isShadeLayoutWide.collectAsStateWithLifecycle() val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle() val areNotificationsVisible by - viewModel - .areNotificationsVisible(contentKey) - .collectAsStateWithLifecycle(initialValue = false) + viewModel.areNotificationsVisible().collectAsStateWithLifecycle(initialValue = false) val isBypassEnabled by viewModel.isBypassEnabled.collectAsStateWithLifecycle() if (isBypassEnabled) { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt index 8236eece9069..6f7e9d3bc59d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt @@ -128,8 +128,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa fun areNotificationsVisible_splitShadeTrue_true() = with(kosmos) { testScope.runTest { - val areNotificationsVisible by - collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen)) + val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible()) shadeRepository.setShadeLayoutWide(true) fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE) @@ -142,36 +141,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa fun areNotificationsVisible_dualShadeWideOnLockscreen_true() = with(kosmos) { testScope.runTest { - val areNotificationsVisible by - collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen)) - shadeRepository.setShadeLayoutWide(true) - fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE) - - assertThat(areNotificationsVisible).isTrue() - } - } - - @Test - @EnableFlags(DualShade.FLAG_NAME) - fun areNotificationsVisible_dualShadeWideOnNotificationsShade_false() = - with(kosmos) { - testScope.runTest { - val areNotificationsVisible by - collectLastValue(underTest.areNotificationsVisible(Scenes.NotificationsShade)) - shadeRepository.setShadeLayoutWide(true) - fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE) - - assertThat(areNotificationsVisible).isFalse() - } - } - - @Test - @EnableFlags(DualShade.FLAG_NAME) - fun areNotificationsVisible_dualShadeWideOnQuickSettingsShade_true() = - with(kosmos) { - testScope.runTest { - val areNotificationsVisible by - collectLastValue(underTest.areNotificationsVisible(Scenes.QuickSettingsShade)) + val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible()) shadeRepository.setShadeLayoutWide(true) fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE) @@ -184,8 +154,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa fun areNotificationsVisible_withSmallClock_true() = with(kosmos) { testScope.runTest { - val areNotificationsVisible by - collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen)) + val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible()) fakeKeyguardClockRepository.setClockSize(ClockSize.SMALL) assertThat(areNotificationsVisible).isTrue() } @@ -196,8 +165,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa fun areNotificationsVisible_withLargeClock_false() = with(kosmos) { testScope.runTest { - val areNotificationsVisible by - collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen)) + val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible()) fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE) assertThat(areNotificationsVisible).isFalse() } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt index adb63b7b3e69..75b1b0402630 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt @@ -17,7 +17,6 @@ package com.android.systemui.keyguard.ui.viewmodel import android.content.res.Resources -import com.android.compose.animation.scene.ContentKey import com.android.internal.annotations.VisibleForTesting import com.android.systemui.biometrics.AuthController import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor @@ -27,7 +26,6 @@ import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.lifecycle.ExclusiveActivatable import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor -import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.unfold.domain.interactor.UnfoldTransitionInteractor import dagger.assisted.AssistedFactory @@ -42,7 +40,6 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch @@ -103,17 +100,8 @@ constructor( } } - /** - * Returns a flow that indicates whether lockscreen notifications should be rendered in the - * given [contentKey]. - */ - fun areNotificationsVisible(contentKey: ContentKey): Flow<Boolean> { - // `Scenes.NotificationsShade` renders its own separate notifications stack, so when it's - // open we avoid rendering the lockscreen notifications stack. - if (contentKey == Scenes.NotificationsShade) { - return flowOf(false) - } - + /** Returns a flow that indicates whether lockscreen notifications should be rendered. */ + fun areNotificationsVisible(): Flow<Boolean> { return combine( clockSize, shadeInteractor.isShadeLayoutWide, |