Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryTest.kt +4 −8 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.keyguard.ClockEventController import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.FakeFeatureFlagsClassic import com.android.systemui.flags.Flags Loading Loading @@ -57,12 +58,14 @@ class KeyguardClockRepositoryTest : SysuiTestCase() { private val fakeFeatureFlagsClassic = FakeFeatureFlagsClassic() @Mock private lateinit var resources: Resources @Mock private lateinit var configRepo: ConfigurationRepository private lateinit var testableResources: TestableResources @Before fun setup() { MockitoAnnotations.initMocks(this) fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) testableResources = mContext.getOrCreateTestableResources() testableResources.addOverride( com.android.internal.R.integer.config_doublelineClockDefault, Loading @@ -77,6 +80,7 @@ class KeyguardClockRepositoryTest : SysuiTestCase() { dispatcher, scope.backgroundScope, context, configRepo, fakeFeatureFlagsClassic, ) } Loading @@ -96,12 +100,4 @@ class KeyguardClockRepositoryTest : SysuiTestCase() { val value = collectLastValue(underTest.selectedClockSize) Truth.assertThat(value()).isEqualTo(ClockSizeSetting.DYNAMIC) } @Test fun testShouldForceSmallClock() = scope.runTest { overrideResource(R.bool.force_small_clock_on_lockscreen, true) fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) Truth.assertThat(underTest.shouldForceSmallClock).isTrue() } } packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ class KeyguardClockInteractorTest : SysuiTestCase() { fun clockSize_forceSmallClock_SMALL() = testScope.runTest { val value by collectLastValue(underTest.clockSize) kosmos.fakeKeyguardClockRepository.setShouldForceSmallClock(true) kosmos.fakeKeyguardClockRepository.setClockSize(ClockSize.SMALL) kosmos.fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) fakeKeyguardClockRepository.setShouldForceSmallClock(true) fakeKeyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(currentClockLayout).isEqualTo(ClockLayout.SPLIT_SHADE_SMALL_CLOCK) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt +0 −1 Original line number Diff line number Diff line Loading @@ -250,7 +250,6 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa ShadeMode.Single -> enableSingleShade() ShadeMode.Split -> enableSplitShade() } fakeKeyguardClockRepository.setShouldForceSmallClock(clockSize == ClockSize.SMALL) fakeKeyguardClockRepository.setClockSize(clockSize) kosmos.activeNotificationListRepository.activeNotifications.value = ActiveNotificationsStore.Builder() Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepository.kt +16 −8 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.UserHandle import android.provider.Settings import com.android.keyguard.ClockEventController import com.android.systemui.animation.GSFAxes import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background Loading @@ -46,6 +47,7 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.onStart Loading @@ -72,7 +74,7 @@ interface KeyguardClockRepository { val clockEventController: ClockEventController val shouldForceSmallClock: Boolean val forcedClockSize: Flow<ClockSize?> fun setClockSize(size: ClockSize) } Loading @@ -87,12 +89,24 @@ constructor( @Background private val backgroundDispatcher: CoroutineDispatcher, @Application private val applicationScope: CoroutineScope, @ShadeDisplayAware private val context: Context, @ShadeDisplayAware configurationRepository: ConfigurationRepository, private val featureFlags: FeatureFlagsClassic, ) : KeyguardClockRepository { /** Receive SMALL or LARGE clock should be displayed on keyguard. */ private val _clockSize: MutableStateFlow<ClockSize> = MutableStateFlow(ClockSize.LARGE) override val clockSize: StateFlow<ClockSize> = _clockSize.asStateFlow() override val forcedClockSize: Flow<ClockSize?> = if (featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)) { configurationRepository.onAnyConfigurationChange.map { if (context.resources.getBoolean(R.bool.force_small_clock_on_lockscreen)) { ClockSize.SMALL } else { null } } } else { flowOf<ClockSize?>(null) } override fun setClockSize(size: ClockSize) { SceneContainerFlag.assertInLegacyMode() Loading Loading @@ -146,12 +160,6 @@ constructor( initialValue = null, ) override val shouldForceSmallClock: Boolean get() = featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE) && // True on small landscape screens context.resources.getBoolean(R.bool.force_small_clock_on_lockscreen) private fun getClockSize(): ClockSizeSetting { return ClockSizeSetting.fromSettingValue( secureSettings.getIntForUser( Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryTest.kt +4 −8 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.keyguard.ClockEventController import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.FakeFeatureFlagsClassic import com.android.systemui.flags.Flags Loading Loading @@ -57,12 +58,14 @@ class KeyguardClockRepositoryTest : SysuiTestCase() { private val fakeFeatureFlagsClassic = FakeFeatureFlagsClassic() @Mock private lateinit var resources: Resources @Mock private lateinit var configRepo: ConfigurationRepository private lateinit var testableResources: TestableResources @Before fun setup() { MockitoAnnotations.initMocks(this) fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) testableResources = mContext.getOrCreateTestableResources() testableResources.addOverride( com.android.internal.R.integer.config_doublelineClockDefault, Loading @@ -77,6 +80,7 @@ class KeyguardClockRepositoryTest : SysuiTestCase() { dispatcher, scope.backgroundScope, context, configRepo, fakeFeatureFlagsClassic, ) } Loading @@ -96,12 +100,4 @@ class KeyguardClockRepositoryTest : SysuiTestCase() { val value = collectLastValue(underTest.selectedClockSize) Truth.assertThat(value()).isEqualTo(ClockSizeSetting.DYNAMIC) } @Test fun testShouldForceSmallClock() = scope.runTest { overrideResource(R.bool.force_small_clock_on_lockscreen, true) fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) Truth.assertThat(underTest.shouldForceSmallClock).isTrue() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ class KeyguardClockInteractorTest : SysuiTestCase() { fun clockSize_forceSmallClock_SMALL() = testScope.runTest { val value by collectLastValue(underTest.clockSize) kosmos.fakeKeyguardClockRepository.setShouldForceSmallClock(true) kosmos.fakeKeyguardClockRepository.setClockSize(ClockSize.SMALL) kosmos.fakeFeatureFlagsClassic.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true) kosmos.fakeKeyguardTransitionRepository.transitionTo( KeyguardState.AOD, Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() KeyguardState.AOD, KeyguardState.LOCKSCREEN, ) fakeKeyguardClockRepository.setShouldForceSmallClock(true) fakeKeyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(currentClockLayout).isEqualTo(ClockLayout.SPLIT_SHADE_SMALL_CLOCK) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt +0 −1 Original line number Diff line number Diff line Loading @@ -250,7 +250,6 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa ShadeMode.Single -> enableSingleShade() ShadeMode.Split -> enableSplitShade() } fakeKeyguardClockRepository.setShouldForceSmallClock(clockSize == ClockSize.SMALL) fakeKeyguardClockRepository.setClockSize(clockSize) kosmos.activeNotificationListRepository.activeNotifications.value = ActiveNotificationsStore.Builder() Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepository.kt +16 −8 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.UserHandle import android.provider.Settings import com.android.keyguard.ClockEventController import com.android.systemui.animation.GSFAxes import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background Loading @@ -46,6 +47,7 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.onStart Loading @@ -72,7 +74,7 @@ interface KeyguardClockRepository { val clockEventController: ClockEventController val shouldForceSmallClock: Boolean val forcedClockSize: Flow<ClockSize?> fun setClockSize(size: ClockSize) } Loading @@ -87,12 +89,24 @@ constructor( @Background private val backgroundDispatcher: CoroutineDispatcher, @Application private val applicationScope: CoroutineScope, @ShadeDisplayAware private val context: Context, @ShadeDisplayAware configurationRepository: ConfigurationRepository, private val featureFlags: FeatureFlagsClassic, ) : KeyguardClockRepository { /** Receive SMALL or LARGE clock should be displayed on keyguard. */ private val _clockSize: MutableStateFlow<ClockSize> = MutableStateFlow(ClockSize.LARGE) override val clockSize: StateFlow<ClockSize> = _clockSize.asStateFlow() override val forcedClockSize: Flow<ClockSize?> = if (featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)) { configurationRepository.onAnyConfigurationChange.map { if (context.resources.getBoolean(R.bool.force_small_clock_on_lockscreen)) { ClockSize.SMALL } else { null } } } else { flowOf<ClockSize?>(null) } override fun setClockSize(size: ClockSize) { SceneContainerFlag.assertInLegacyMode() Loading Loading @@ -146,12 +160,6 @@ constructor( initialValue = null, ) override val shouldForceSmallClock: Boolean get() = featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE) && // True on small landscape screens context.resources.getBoolean(R.bool.force_small_clock_on_lockscreen) private fun getClockSize(): ClockSizeSetting { return ClockSizeSetting.fromSettingValue( secureSettings.getIntForUser( Loading