Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt +190 −23 Original line number Diff line number Diff line Loading @@ -25,13 +25,14 @@ import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.keyguardClockRepository import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.media.controls.data.repository.mediaFilterRepository Loading Loading @@ -74,18 +75,6 @@ class KeyguardClockInteractorTest : SysuiTestCase() { assertThat(value).isEqualTo(ClockSize.SMALL) } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_basedOnRepository() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.keyguardInteractor.setClockShouldBeCentered(true) assertThat(value).isTrue() kosmos.keyguardInteractor.setClockShouldBeCentered(false) assertThat(value).isFalse() } @Test @EnableSceneContainer fun clockSize_forceSmallClock_SMALL() = Loading @@ -93,7 +82,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() { val value by collectLastValue(underTest.clockSize) kosmos.fakeKeyguardClockRepository.setShouldForceSmallClock(true) kosmos.fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) transitionTo(KeyguardState.AOD, KeyguardState.LOCKSCREEN) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isEqualTo(ClockSize.SMALL) } Loading Loading @@ -190,7 +182,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) transitionTo(KeyguardState.LOCKSCREEN, KeyguardState.AOD) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() } Loading @@ -201,15 +196,187 @@ class KeyguardClockInteractorTest : SysuiTestCase() { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) transitionTo(KeyguardState.AOD, KeyguardState.LOCKSCREEN) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_notSplitMode_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(false) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_lockscreen_withNotifs_false() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_lockscreen_withoutNotifs_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_LsToAod_withNotifs_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.OFF, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_AodToLs_withNotifs_false() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() } private suspend fun transitionTo(from: KeyguardState, to: KeyguardState) { with(kosmos.fakeKeyguardTransitionRepository) { sendTransitionStep(TransitionStep(from, to, 0f, TransitionState.STARTED)) sendTransitionStep(TransitionStep(from, to, 0.5f, TransitionState.RUNNING)) sendTransitionStep(TransitionStep(from, to, 1f, TransitionState.FINISHED)) @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_Aod_withPulsingNotifs_false() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() kosmos.fakeKeyguardRepository.setDozeTransitionModel( DozeTransitionModel( from = DozeStateModel.DOZE_AOD, to = DozeStateModel.DOZE_PULSING, ) ) assertThat(value).isFalse() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_LStoGone_withoutNotifs_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.OFF, KeyguardState.LOCKSCREEN, ) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.GONE, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_AodOn_GoneToAOD() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.GONE, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.GONE, KeyguardState.AOD, ) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_AodOff_GoneToDoze() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.DOZING, KeyguardState.LOCKSCREEN, ) kosmos.activeNotificationListRepository.setActiveNotifs(0) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.GONE, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.GONE, KeyguardState.DOZING, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.DOZING, KeyguardState.LOCKSCREEN, ) kosmos.activeNotificationListRepository.setActiveNotifs(0) assertThat(value).isTrue() } } packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt +0 −6 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.customization.R as customR import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.domain.interactor.keyguardBlueprintInteractor import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor import com.android.systemui.keyguard.domain.interactor.keyguardSmartspaceInteractor Loading Loading @@ -156,7 +155,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(false) keyguardClockInteractor.setClockSize(ClockSize.LARGE) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -181,7 +179,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(true) keyguardClockInteractor.setClockSize(ClockSize.LARGE) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -206,7 +203,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(false) keyguardClockInteractor.setClockSize(ClockSize.LARGE) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -230,7 +226,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(true) keyguardClockInteractor.setClockSize(ClockSize.SMALL) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -254,7 +249,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(false) keyguardClockInteractor.setClockSize(ClockSize.SMALL) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt +30 −16 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.BrokenWithSceneContainer import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.keyguardClockRepository import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.shared.model.ClockSizeSetting import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel.ClockLayout import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.clocks.ClockConfig Loading @@ -37,6 +37,8 @@ import com.android.systemui.plugins.clocks.ClockFaceConfig import com.android.systemui.plugins.clocks.ClockFaceController import com.android.systemui.res.R import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs import com.android.systemui.statusbar.ui.fakeSystemBarUtilsProxy import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever Loading Loading @@ -87,7 +89,11 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() with(kosmos) { shadeRepository.setShadeLayoutWide(true) keyguardRepository.setClockShouldBeCentered(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) keyguardClockRepository.setClockSize(ClockSize.LARGE) } Loading @@ -95,14 +101,18 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) @EnableSceneContainer fun currentClockLayout_splitShadeOn_clockNotCentered_largeClock_splitShadeLargeClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(true) keyguardRepository.setClockShouldBeCentered(false) activeNotificationListRepository.setActiveNotifs(1) fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) keyguardClockRepository.setClockSize(ClockSize.LARGE) } Loading @@ -110,42 +120,46 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) fun currentClockLayout_splitShadeOn_clockNotCentered_smallClock_splitShadeSmallClock() = @EnableSceneContainer fun currentClockLayout_splitShadeOn_clockNotCentered_forceSmallClock_splitShadeSmallClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(true) keyguardRepository.setClockShouldBeCentered(false) keyguardClockRepository.setClockSize(ClockSize.SMALL) activeNotificationListRepository.setActiveNotifs(1) fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) fakeKeyguardClockRepository.setShouldForceSmallClock(true) } assertThat(currentClockLayout).isEqualTo(ClockLayout.SPLIT_SHADE_SMALL_CLOCK) } @Test @BrokenWithSceneContainer(339465026) fun currentClockLayout_singleShade_smallClock_smallClock() = @EnableSceneContainer fun currentClockLayout_singleShade_withNotifs_smallClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(false) keyguardClockRepository.setClockSize(ClockSize.SMALL) activeNotificationListRepository.setActiveNotifs(1) } assertThat(currentClockLayout).isEqualTo(ClockLayout.SMALL_CLOCK) } @Test fun currentClockLayout_singleShade_largeClock_largeClock() = fun currentClockLayout_singleShade_withoutNotifs_largeClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(false) keyguardClockRepository.setClockSize(ClockSize.LARGE) activeNotificationListRepository.setActiveNotifs(0) } assertThat(currentClockLayout).isEqualTo(ClockLayout.LARGE_CLOCK) Loading Loading @@ -195,7 +209,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) @DisableSceneContainer fun testClockSize_dynamicClockSize() = testScope.runTest { with(kosmos) { Loading @@ -219,7 +233,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) @DisableSceneContainer fun isLargeClockVisible_whenSmallClockSize_isFalse() = testScope.runTest { val value by collectLastValue(underTest.isLargeClockVisible) Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +1 −17 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.keyguard.data.repository import android.graphics.Point import com.android.app.tracing.coroutines.launchTraced as launch import com.android.internal.widget.LockPatternUtils import com.android.keyguard.KeyguardUpdateMonitor import com.android.keyguard.KeyguardUpdateMonitorCallback Loading Loading @@ -64,7 +65,6 @@ import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import com.android.app.tracing.coroutines.launchTraced as launch /** Defines interface for classes that encapsulate application state for the keyguard. */ interface KeyguardRepository { Loading Loading @@ -247,13 +247,6 @@ interface KeyguardRepository { ) val keyguardDoneAnimationsFinished: Flow<Unit> /** * Receive whether clock should be centered on lockscreen. * * @deprecated When scene container flag is on use clockShouldBeCentered from domain level. */ val clockShouldBeCentered: Flow<Boolean> /** * Whether the primary authentication is required for the given user due to lockdown or * encryption after reboot. Loading Loading @@ -306,8 +299,6 @@ interface KeyguardRepository { suspend fun setKeyguardDone(keyguardDoneType: KeyguardDone) fun setClockShouldBeCentered(shouldBeCentered: Boolean) /** * Updates signal that the keyguard done animations are finished * Loading Loading @@ -390,9 +381,6 @@ constructor( override val panelAlpha: MutableStateFlow<Float> = MutableStateFlow(1f) private val _clockShouldBeCentered = MutableStateFlow(true) override val clockShouldBeCentered: Flow<Boolean> = _clockShouldBeCentered.asStateFlow() override val topClippingBounds = MutableStateFlow<Int?>(null) override val isKeyguardShowing: MutableStateFlow<Boolean> = Loading Loading @@ -681,10 +669,6 @@ constructor( _isQuickSettingsVisible.value = isVisible } override fun setClockShouldBeCentered(shouldBeCentered: Boolean) { _clockShouldBeCentered.value = shouldBeCentered } override fun setKeyguardEnabled(enabled: Boolean) { _isKeyguardEnabled.value = enabled } Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt +42 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,10 @@ import com.android.systemui.keyguard.data.repository.KeyguardClockRepository import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.shared.model.ClockSizeSetting import com.android.systemui.keyguard.shared.model.KeyguardState 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.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.media.controls.domain.pipeline.interactor.MediaCarouselInteractor import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockId Loading @@ -39,6 +43,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn Loading Loading @@ -117,7 +122,43 @@ constructor( } } } else { keyguardInteractor.clockShouldBeCentered combine( shadeInteractor.isShadeLayoutWide, activeNotificationsInteractor.areAnyNotificationsPresent, keyguardInteractor.dozeTransitionModel, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == AOD }, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == LOCKSCREEN }, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == DOZING }, keyguardInteractor.isPulsing, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == GONE }, ) { isShadeLayoutWide, areAnyNotificationsPresent, dozeTransitionModel, startedToAod, startedToLockScreen, startedToDoze, isPulsing, startedToGone -> when { !isShadeLayoutWide -> true // [areAnyNotificationsPresent] also reacts to notification stack in // homescreen // it may cause unnecessary `false` emission when there's notification in // homescreen // but none in lockscreen when going from GONE to AOD / DOZING // use null to skip emitting wrong value startedToGone || startedToDoze -> null startedToLockScreen -> !areAnyNotificationsPresent startedToAod -> !isPulsing else -> true } } .filterNotNull() } fun setClockSize(size: ClockSize) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt +190 −23 Original line number Diff line number Diff line Loading @@ -25,13 +25,14 @@ import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.keyguardClockRepository import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.media.controls.data.repository.mediaFilterRepository Loading Loading @@ -74,18 +75,6 @@ class KeyguardClockInteractorTest : SysuiTestCase() { assertThat(value).isEqualTo(ClockSize.SMALL) } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_basedOnRepository() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.keyguardInteractor.setClockShouldBeCentered(true) assertThat(value).isTrue() kosmos.keyguardInteractor.setClockShouldBeCentered(false) assertThat(value).isFalse() } @Test @EnableSceneContainer fun clockSize_forceSmallClock_SMALL() = Loading @@ -93,7 +82,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() { val value by collectLastValue(underTest.clockSize) kosmos.fakeKeyguardClockRepository.setShouldForceSmallClock(true) kosmos.fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) transitionTo(KeyguardState.AOD, KeyguardState.LOCKSCREEN) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isEqualTo(ClockSize.SMALL) } Loading Loading @@ -190,7 +182,10 @@ class KeyguardClockInteractorTest : SysuiTestCase() { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) transitionTo(KeyguardState.LOCKSCREEN, KeyguardState.AOD) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() } Loading @@ -201,15 +196,187 @@ class KeyguardClockInteractorTest : SysuiTestCase() { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) transitionTo(KeyguardState.AOD, KeyguardState.LOCKSCREEN) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_notSplitMode_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(false) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_lockscreen_withNotifs_false() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_lockscreen_withoutNotifs_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_LsToAod_withNotifs_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.OFF, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_AodToLs_withNotifs_false() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(1) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) assertThat(value).isFalse() } private suspend fun transitionTo(from: KeyguardState, to: KeyguardState) { with(kosmos.fakeKeyguardTransitionRepository) { sendTransitionStep(TransitionStep(from, to, 0f, TransitionState.STARTED)) sendTransitionStep(TransitionStep(from, to, 0.5f, TransitionState.RUNNING)) sendTransitionStep(TransitionStep(from, to, 1f, TransitionState.FINISHED)) @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_Aod_withPulsingNotifs_false() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.AOD, ) assertThat(value).isTrue() kosmos.fakeKeyguardRepository.setDozeTransitionModel( DozeTransitionModel( from = DozeStateModel.DOZE_AOD, to = DozeStateModel.DOZE_PULSING, ) ) assertThat(value).isFalse() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_LStoGone_withoutNotifs_true() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.OFF, KeyguardState.LOCKSCREEN, ) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.GONE, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_AodOn_GoneToAOD() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.GONE, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.GONE, KeyguardState.AOD, ) assertThat(value).isTrue() } @Test @DisableSceneContainer fun clockShouldBeCentered_sceneContainerFlagOff_splitMode_AodOff_GoneToDoze() = testScope.runTest { val value by collectLastValue(underTest.clockShouldBeCentered) kosmos.shadeRepository.setShadeLayoutWide(true) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.DOZING, KeyguardState.LOCKSCREEN, ) kosmos.activeNotificationListRepository.setActiveNotifs(0) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.LOCKSCREEN, KeyguardState.GONE, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.GONE, KeyguardState.DOZING, ) kosmos.activeNotificationListRepository.setActiveNotifs(1) assertThat(value).isTrue() kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.DOZING, KeyguardState.LOCKSCREEN, ) kosmos.activeNotificationListRepository.setActiveNotifs(0) assertThat(value).isTrue() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt +0 −6 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.customization.R as customR import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.domain.interactor.keyguardBlueprintInteractor import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor import com.android.systemui.keyguard.domain.interactor.keyguardSmartspaceInteractor Loading Loading @@ -156,7 +155,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(false) keyguardClockInteractor.setClockSize(ClockSize.LARGE) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -181,7 +179,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(true) keyguardClockInteractor.setClockSize(ClockSize.LARGE) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -206,7 +203,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(false) keyguardClockInteractor.setClockSize(ClockSize.LARGE) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -230,7 +226,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(true) keyguardClockInteractor.setClockSize(ClockSize.SMALL) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading @@ -254,7 +249,6 @@ class ClockSectionTest : SysuiTestCase() { shadeRepository.setShadeLayoutWide(false) keyguardClockInteractor.setClockSize(ClockSize.SMALL) fakeKeyguardRepository.setClockShouldBeCentered(true) notificationsKeyguardInteractor.setNotificationsFullyHidden(true) keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE) fakeConfigurationController.notifyConfigurationChanged() Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt +30 −16 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.BrokenWithSceneContainer import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.keyguardClockRepository import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.shared.model.ClockSizeSetting import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel.ClockLayout import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.clocks.ClockConfig Loading @@ -37,6 +37,8 @@ import com.android.systemui.plugins.clocks.ClockFaceConfig import com.android.systemui.plugins.clocks.ClockFaceController import com.android.systemui.res.R import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs import com.android.systemui.statusbar.ui.fakeSystemBarUtilsProxy import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever Loading Loading @@ -87,7 +89,11 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() with(kosmos) { shadeRepository.setShadeLayoutWide(true) keyguardRepository.setClockShouldBeCentered(true) kosmos.activeNotificationListRepository.setActiveNotifs(0) fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) keyguardClockRepository.setClockSize(ClockSize.LARGE) } Loading @@ -95,14 +101,18 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) @EnableSceneContainer fun currentClockLayout_splitShadeOn_clockNotCentered_largeClock_splitShadeLargeClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(true) keyguardRepository.setClockShouldBeCentered(false) activeNotificationListRepository.setActiveNotifs(1) fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) keyguardClockRepository.setClockSize(ClockSize.LARGE) } Loading @@ -110,42 +120,46 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) fun currentClockLayout_splitShadeOn_clockNotCentered_smallClock_splitShadeSmallClock() = @EnableSceneContainer fun currentClockLayout_splitShadeOn_clockNotCentered_forceSmallClock_splitShadeSmallClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(true) keyguardRepository.setClockShouldBeCentered(false) keyguardClockRepository.setClockSize(ClockSize.SMALL) activeNotificationListRepository.setActiveNotifs(1) fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) fakeKeyguardClockRepository.setShouldForceSmallClock(true) } assertThat(currentClockLayout).isEqualTo(ClockLayout.SPLIT_SHADE_SMALL_CLOCK) } @Test @BrokenWithSceneContainer(339465026) fun currentClockLayout_singleShade_smallClock_smallClock() = @EnableSceneContainer fun currentClockLayout_singleShade_withNotifs_smallClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(false) keyguardClockRepository.setClockSize(ClockSize.SMALL) activeNotificationListRepository.setActiveNotifs(1) } assertThat(currentClockLayout).isEqualTo(ClockLayout.SMALL_CLOCK) } @Test fun currentClockLayout_singleShade_largeClock_largeClock() = fun currentClockLayout_singleShade_withoutNotifs_largeClock() = testScope.runTest { val currentClockLayout by collectLastValue(underTest.currentClockLayout) with(kosmos) { shadeRepository.setShadeLayoutWide(false) keyguardClockRepository.setClockSize(ClockSize.LARGE) activeNotificationListRepository.setActiveNotifs(0) } assertThat(currentClockLayout).isEqualTo(ClockLayout.LARGE_CLOCK) Loading Loading @@ -195,7 +209,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) @DisableSceneContainer fun testClockSize_dynamicClockSize() = testScope.runTest { with(kosmos) { Loading @@ -219,7 +233,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() } @Test @BrokenWithSceneContainer(339465026) @DisableSceneContainer fun isLargeClockVisible_whenSmallClockSize_isFalse() = testScope.runTest { val value by collectLastValue(underTest.isLargeClockVisible) Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +1 −17 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.keyguard.data.repository import android.graphics.Point import com.android.app.tracing.coroutines.launchTraced as launch import com.android.internal.widget.LockPatternUtils import com.android.keyguard.KeyguardUpdateMonitor import com.android.keyguard.KeyguardUpdateMonitorCallback Loading Loading @@ -64,7 +65,6 @@ import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import com.android.app.tracing.coroutines.launchTraced as launch /** Defines interface for classes that encapsulate application state for the keyguard. */ interface KeyguardRepository { Loading Loading @@ -247,13 +247,6 @@ interface KeyguardRepository { ) val keyguardDoneAnimationsFinished: Flow<Unit> /** * Receive whether clock should be centered on lockscreen. * * @deprecated When scene container flag is on use clockShouldBeCentered from domain level. */ val clockShouldBeCentered: Flow<Boolean> /** * Whether the primary authentication is required for the given user due to lockdown or * encryption after reboot. Loading Loading @@ -306,8 +299,6 @@ interface KeyguardRepository { suspend fun setKeyguardDone(keyguardDoneType: KeyguardDone) fun setClockShouldBeCentered(shouldBeCentered: Boolean) /** * Updates signal that the keyguard done animations are finished * Loading Loading @@ -390,9 +381,6 @@ constructor( override val panelAlpha: MutableStateFlow<Float> = MutableStateFlow(1f) private val _clockShouldBeCentered = MutableStateFlow(true) override val clockShouldBeCentered: Flow<Boolean> = _clockShouldBeCentered.asStateFlow() override val topClippingBounds = MutableStateFlow<Int?>(null) override val isKeyguardShowing: MutableStateFlow<Boolean> = Loading Loading @@ -681,10 +669,6 @@ constructor( _isQuickSettingsVisible.value = isVisible } override fun setClockShouldBeCentered(shouldBeCentered: Boolean) { _clockShouldBeCentered.value = shouldBeCentered } override fun setKeyguardEnabled(enabled: Boolean) { _isKeyguardEnabled.value = enabled } Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt +42 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,10 @@ import com.android.systemui.keyguard.data.repository.KeyguardClockRepository import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.shared.model.ClockSizeSetting import com.android.systemui.keyguard.shared.model.KeyguardState 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.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.media.controls.domain.pipeline.interactor.MediaCarouselInteractor import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockId Loading @@ -39,6 +43,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn Loading Loading @@ -117,7 +122,43 @@ constructor( } } } else { keyguardInteractor.clockShouldBeCentered combine( shadeInteractor.isShadeLayoutWide, activeNotificationsInteractor.areAnyNotificationsPresent, keyguardInteractor.dozeTransitionModel, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == AOD }, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == LOCKSCREEN }, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == DOZING }, keyguardInteractor.isPulsing, keyguardTransitionInteractor.startedKeyguardTransitionStep.map { it.to == GONE }, ) { isShadeLayoutWide, areAnyNotificationsPresent, dozeTransitionModel, startedToAod, startedToLockScreen, startedToDoze, isPulsing, startedToGone -> when { !isShadeLayoutWide -> true // [areAnyNotificationsPresent] also reacts to notification stack in // homescreen // it may cause unnecessary `false` emission when there's notification in // homescreen // but none in lockscreen when going from GONE to AOD / DOZING // use null to skip emitting wrong value startedToGone || startedToDoze -> null startedToLockScreen -> !areAnyNotificationsPresent startedToAod -> !isPulsing else -> true } } .filterNotNull() } fun setClockSize(size: ClockSize) { Loading