Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c135907 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update ClockSize logic to enable a test override with flexiglass" into main

parents d9d83fd9 618b44b3
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -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
@@ -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,
@@ -77,6 +80,7 @@ class KeyguardClockRepositoryTest : SysuiTestCase() {
                dispatcher,
                scope.backgroundScope,
                context,
                configRepo,
                fakeFeatureFlagsClassic,
            )
    }
@@ -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()
        }
}
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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)
+0 −1
Original line number Diff line number Diff line
@@ -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()
+16 −8
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -72,7 +74,7 @@ interface KeyguardClockRepository {

    val clockEventController: ClockEventController

    val shouldForceSmallClock: Boolean
    val forcedClockSize: Flow<ClockSize?>

    fun setClockSize(size: ClockSize)
}
@@ -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()
@@ -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