summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sherry Zhou <yuandizhou@google.com> 2025-01-07 13:10:11 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-01-07 13:10:11 -0800
commit7f76c9afbbacf98514e525e38b5fe0c1d93af3db (patch)
treee5ef0b1dcaad5a870635f6051ced09dda1664c63
parenta2c3deb934dedc3c7d3058c283baa8e9be02c0fc (diff)
parentf34b8d4b4232b0dcc8b05bc539bbb166c609d6e6 (diff)
Merge "Fix wrong state of clockShouldBeCentered when notification is being added or removed" into main
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt213
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt6
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt46
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt18
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt43
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java1
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt7
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt6
9 files changed, 269 insertions, 77 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt
index e60d971c7289..282bebcd629a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt
@@ -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
@@ -75,25 +76,16 @@ class KeyguardClockInteractorTest : SysuiTestCase() {
}
@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() =
testScope.runTest {
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)
}
@@ -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()
}
@@ -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()
}
- 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_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()
+ }
+
+ @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()
}
- }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
index 87ab3c89a671..1cf45f8f8b8e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
@@ -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
@@ -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()
@@ -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()
@@ -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()
@@ -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()
@@ -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()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt
index 05a6b8785daf..8a599a1bd948 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt
@@ -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
@@ -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
@@ -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)
}
@@ -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)
}
@@ -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)
@@ -195,7 +209,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
}
@Test
- @BrokenWithSceneContainer(339465026)
+ @DisableSceneContainer
fun testClockSize_dynamicClockSize() =
testScope.runTest {
with(kosmos) {
@@ -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)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
index ac04dd5a7ec1..a39982dd31e7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
@@ -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
@@ -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 {
@@ -248,13 +248,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.
*/
@@ -306,8 +299,6 @@ interface KeyguardRepository {
suspend fun setKeyguardDone(keyguardDoneType: KeyguardDone)
- fun setClockShouldBeCentered(shouldBeCentered: Boolean)
-
/**
* Updates signal that the keyguard done animations are finished
*
@@ -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> =
@@ -681,10 +669,6 @@ constructor(
_isQuickSettingsVisible.value = isVisible
}
- override fun setClockShouldBeCentered(shouldBeCentered: Boolean) {
- _clockShouldBeCentered.value = shouldBeCentered
- }
-
override fun setKeyguardEnabled(enabled: Boolean) {
_isKeyguardEnabled.value = enabled
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt
index f792935e67f3..ab5fdd608d03 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt
@@ -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
@@ -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
@@ -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) {
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 0193d7cba616..fbe31bbf36e6 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
@@ -418,8 +418,6 @@ constructor(
initialValue = 0f,
)
- val clockShouldBeCentered: Flow<Boolean> = repository.clockShouldBeCentered
-
/** Whether to animate the next doze mode transition. */
val animateDozingTransitions: Flow<Boolean> by lazy {
if (SceneContainerFlag.isEnabled) {
@@ -485,10 +483,6 @@ constructor(
repository.setAnimateDozingTransitions(animate)
}
- fun setClockShouldBeCentered(shouldBeCentered: Boolean) {
- repository.setClockShouldBeCentered(shouldBeCentered)
- }
-
fun setLastRootViewTapPosition(point: Point?) {
repository.lastRootViewTapPosition.value = point
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index c9eb4962ab00..745f7cb47b36 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -1183,7 +1183,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
private void updateKeyguardStatusViewAlignment(boolean animate) {
boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered();
mKeyguardUnfoldTransition.ifPresent(t -> t.setStatusViewCentered(shouldBeCentered));
- mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered);
}
private boolean shouldKeyguardStatusViewBeCentered() {
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
index 1288d3151051..8489d8380041 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
@@ -46,9 +46,6 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository {
MutableSharedFlow(extraBufferCapacity = 1)
override val keyguardDoneAnimationsFinished: Flow<Unit> = _keyguardDoneAnimationsFinished
- private val _clockShouldBeCentered = MutableStateFlow<Boolean>(true)
- override val clockShouldBeCentered: Flow<Boolean> = _clockShouldBeCentered
-
private val _dismissAction = MutableStateFlow<DismissAction>(DismissAction.None)
override val dismissAction: StateFlow<DismissAction> = _dismissAction
@@ -192,10 +189,6 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository {
_keyguardDoneAnimationsFinished.tryEmit(Unit)
}
- override fun setClockShouldBeCentered(shouldBeCentered: Boolean) {
- _clockShouldBeCentered.value = shouldBeCentered
- }
-
override fun setKeyguardEnabled(enabled: Boolean) {
_isKeyguardEnabled.value = enabled
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt
index 8209ee12ad9a..f4791003c828 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt
@@ -402,6 +402,12 @@ class FakeKeyguardTransitionRepository(
)
)
}
+
+ suspend fun transitionTo(from: KeyguardState, to: KeyguardState) {
+ sendTransitionStep(TransitionStep(from, to, 0f, TransitionState.STARTED))
+ sendTransitionStep(TransitionStep(from, to, 0.5f, TransitionState.RUNNING))
+ sendTransitionStep(TransitionStep(from, to, 1f, TransitionState.FINISHED))
+ }
}
@Module