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

Commit da353650 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Move doze and idle check to outside condition." into main

parents 84134476 d84e8a62
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -306,6 +306,25 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() {
            assertThat(ambientLightModeMonitor.fake.started).isFalse()
        }

    @Test
    fun testDoNotSubscribeIfDozeForLowLightBehaviorPluggedIn() =
        kosmos.runTest {
            lowLightRepository.addAction(LowLightDisplayBehavior.LOW_LIGHT_DREAM, action)
            lowLightSettingsRepository.setLowLightDisplayBehavior(
                LowLightDisplayBehavior.LOW_LIGHT_DREAM
            )

            setBatteryPluggedIn(true)
            setDisplayOn(true)

            fakeKeyguardRepository.setDozeTransitionModel(
                DozeTransitionModel(from = DozeStateModel.UNINITIALIZED, to = DozeStateModel.DOZE)
            )

            underTest.start()
            assertThat(ambientLightModeMonitor.fake.started).isFalse()
        }

    private fun Kosmos.setLowLightFromSensor(lowlight: Boolean) {
        val lightMode =
            if (lowlight) {
+11 −13
Original line number Diff line number Diff line
@@ -158,6 +158,10 @@ constructor(
                anyOf(isScreenOn, flowOf(behavior.allowedInScreenState(ScreenState.OFF))),
                dreamSettingsInteractor.dreamingEnabled,
                isPluggedIn,
                anyOf(
                    isDeviceIdleAndNotDozing,
                    flowOf(behavior.allowedInScreenState(ScreenState.DOZE)),
                ),
            )
            .flatMapLatestConflated {
                // The second set of conditions are separated from the above allOf flow combination
@@ -169,11 +173,6 @@ constructor(
                // Force lowlight only if idle and in either direct-boot
                // mode or in a lowlight environment.
                if (it) {
                    allOf(
                        anyOf(
                            isDeviceIdleAndNotDozing,
                            flowOf(behavior.allowedInScreenState(ScreenState.DOZE)),
                        ),
                    anyOf(
                        isLowLight,
                        if (lowLightSettingsInteractor.allowLowLightBehaviorWhenLocked) {
@@ -181,7 +180,6 @@ constructor(
                        } else {
                            flowOf(false)
                        },
                        ),
                    )
                } else {
                    flowOf(false)