Loading packages/SystemUI/multivalentTests/src/com/android/systemui/lowlight/LowLightBehaviorCoreStartableTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.data.repository.batteryRepository import com.android.systemui.common.data.repository.fake import com.android.systemui.common.domain.interactor.batteryInteractor import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.display.domain.interactor.displayStateInteractor import com.android.systemui.dreams.domain.interactor.dreamSettingsInteractorKosmos Loading Loading @@ -84,6 +87,7 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { lowLightBehaviorShellCommand = lowLightBehaviorShellCommand, lowLightShellCommand = lowLightShellCommand, scope = backgroundScope, batteryInteractor = batteryInteractor, ) } Loading @@ -91,6 +95,10 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { displayRepository.setDefaultDisplayOff(!screenOn) } private fun Kosmos.setBatteryPluggedIn(pluggedIn: Boolean) { batteryRepository.fake.setDevicePluggedIn(pluggedIn) } private fun Kosmos.setDreamEnabled(enabled: Boolean) { fakeSettings.putBoolForUser( Settings.Secure.SCREENSAVER_ENABLED, Loading Loading @@ -142,6 +150,8 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { ) } kosmos.lowLightRepository.addAction(LowLightDisplayBehavior.LOW_LIGHT_DREAM, action) kosmos.batteryRepository.fake.setDevicePluggedIn(true) } @Test Loading Loading @@ -266,6 +276,7 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { LowLightDisplayBehavior.SCREEN_OFF ) setBatteryPluggedIn(true) setDisplayOn(true) fakeKeyguardRepository.setDozeTransitionModel( Loading @@ -276,6 +287,25 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { assertThat(ambientLightModeMonitor.fake.started).isTrue() } @Test fun testDoNotSubscribeIfDozingForScreenOffBehaviorUnplugged() = kosmos.runTest { lowLightRepository.addAction(LowLightDisplayBehavior.SCREEN_OFF, action) lowLightSettingsRepository.setLowLightDisplayBehavior( LowLightDisplayBehavior.SCREEN_OFF ) setBatteryPluggedIn(false) 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) { Loading packages/SystemUI/src/com/android/systemui/lowlight/LowLightBehaviorCoreStartable.kt +6 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.os.Flags import android.os.UserHandle import com.android.internal.logging.UiEventLogger import com.android.systemui.CoreStartable import com.android.systemui.common.domain.interactor.BatteryInteractor import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.display.domain.interactor.DisplayStateInteractor import com.android.systemui.dreams.domain.interactor.DreamSettingsInteractor Loading Loading @@ -74,11 +75,15 @@ constructor( private val uiEventLogger: UiEventLogger, private val lowLightBehaviorShellCommand: LowLightBehaviorShellCommand, private val lowLightShellCommand: LowLightShellCommand, batteryInteractor: BatteryInteractor, ) : CoreStartable { /** Whether the screen is currently on. */ private val isScreenOn = not(displayStateInteractor.isDefaultDisplayOff).distinctUntilChanged() /** Whether device is plugged in */ private val isPluggedIn = batteryInteractor.isDevicePluggedIn.distinctUntilChanged() /** Whether the device is currently in a low-light environment. */ private val isLowLightFromSensor = if (Flags.lowLightDreamBehavior()) { Loading Loading @@ -152,6 +157,7 @@ constructor( return allOf( anyOf(isScreenOn, flowOf(behavior.allowedInScreenState(ScreenState.OFF))), dreamSettingsInteractor.dreamingEnabled, isPluggedIn, ) .flatMapLatestConflated { // The second set of conditions are separated from the above allOf flow combination Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/lowlight/LowLightBehaviorCoreStartableTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,9 @@ import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.data.repository.batteryRepository import com.android.systemui.common.data.repository.fake import com.android.systemui.common.domain.interactor.batteryInteractor import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.display.domain.interactor.displayStateInteractor import com.android.systemui.dreams.domain.interactor.dreamSettingsInteractorKosmos Loading Loading @@ -84,6 +87,7 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { lowLightBehaviorShellCommand = lowLightBehaviorShellCommand, lowLightShellCommand = lowLightShellCommand, scope = backgroundScope, batteryInteractor = batteryInteractor, ) } Loading @@ -91,6 +95,10 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { displayRepository.setDefaultDisplayOff(!screenOn) } private fun Kosmos.setBatteryPluggedIn(pluggedIn: Boolean) { batteryRepository.fake.setDevicePluggedIn(pluggedIn) } private fun Kosmos.setDreamEnabled(enabled: Boolean) { fakeSettings.putBoolForUser( Settings.Secure.SCREENSAVER_ENABLED, Loading Loading @@ -142,6 +150,8 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { ) } kosmos.lowLightRepository.addAction(LowLightDisplayBehavior.LOW_LIGHT_DREAM, action) kosmos.batteryRepository.fake.setDevicePluggedIn(true) } @Test Loading Loading @@ -266,6 +276,7 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { LowLightDisplayBehavior.SCREEN_OFF ) setBatteryPluggedIn(true) setDisplayOn(true) fakeKeyguardRepository.setDozeTransitionModel( Loading @@ -276,6 +287,25 @@ class LowLightBehaviorCoreStartableTest : SysuiTestCase() { assertThat(ambientLightModeMonitor.fake.started).isTrue() } @Test fun testDoNotSubscribeIfDozingForScreenOffBehaviorUnplugged() = kosmos.runTest { lowLightRepository.addAction(LowLightDisplayBehavior.SCREEN_OFF, action) lowLightSettingsRepository.setLowLightDisplayBehavior( LowLightDisplayBehavior.SCREEN_OFF ) setBatteryPluggedIn(false) 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) { Loading
packages/SystemUI/src/com/android/systemui/lowlight/LowLightBehaviorCoreStartable.kt +6 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.os.Flags import android.os.UserHandle import com.android.internal.logging.UiEventLogger import com.android.systemui.CoreStartable import com.android.systemui.common.domain.interactor.BatteryInteractor import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.display.domain.interactor.DisplayStateInteractor import com.android.systemui.dreams.domain.interactor.DreamSettingsInteractor Loading Loading @@ -74,11 +75,15 @@ constructor( private val uiEventLogger: UiEventLogger, private val lowLightBehaviorShellCommand: LowLightBehaviorShellCommand, private val lowLightShellCommand: LowLightShellCommand, batteryInteractor: BatteryInteractor, ) : CoreStartable { /** Whether the screen is currently on. */ private val isScreenOn = not(displayStateInteractor.isDefaultDisplayOff).distinctUntilChanged() /** Whether device is plugged in */ private val isPluggedIn = batteryInteractor.isDevicePluggedIn.distinctUntilChanged() /** Whether the device is currently in a low-light environment. */ private val isLowLightFromSensor = if (Flags.lowLightDreamBehavior()) { Loading Loading @@ -152,6 +157,7 @@ constructor( return allOf( anyOf(isScreenOn, flowOf(behavior.allowedInScreenState(ScreenState.OFF))), dreamSettingsInteractor.dreamingEnabled, isPluggedIn, ) .flatMapLatestConflated { // The second set of conditions are separated from the above allOf flow combination Loading