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

Commit ad1ad796 authored by Coco Duan's avatar Coco Duan
Browse files

Populate a new dreaming state to KeyguardInterator for wallpaper dream

Define a new dreaming state `isActiveDreamLockscreenHosted`
in KeyguardInteractor. The new state will be used to customize
the lockscreen views.
In wallpaper dream service, when dreaming starts/stops the updated
dreaming state will be set in KeyguardInteractor.

Bug: b/285061458
Test: atest KeyguardRepositoryImplTest; on device
Change-Id: I2347e4f1d7bf03ec0a0142671ba7a4157b6b7ab8
parent 95e25521
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -121,6 +121,9 @@ interface KeyguardRepository {
    /** Observable for whether the device is dreaming with an overlay, see [DreamOverlayService] */
    val isDreamingWithOverlay: Flow<Boolean>

    /** Observable for device dreaming state and the active dream is hosted in lockscreen */
    val isActiveDreamLockscreenHosted: StateFlow<Boolean>

    /**
     * Observable for the amount of doze we are currently in.
     *
@@ -190,6 +193,8 @@ interface KeyguardRepository {
    fun setLastDozeTapToWakePosition(position: Point)

    fun setIsDozing(isDozing: Boolean)

    fun setIsActiveDreamLockscreenHosted(isLockscreenHosted: Boolean)
}

/** Encapsulates application state for the keyguard. */
@@ -610,6 +615,9 @@ constructor(
    private val _isQuickSettingsVisible = MutableStateFlow(false)
    override val isQuickSettingsVisible: Flow<Boolean> = _isQuickSettingsVisible.asStateFlow()

    private val _isActiveDreamLockscreenHosted = MutableStateFlow(false)
    override val isActiveDreamLockscreenHosted = _isActiveDreamLockscreenHosted.asStateFlow()

    override fun setAnimateDozingTransitions(animate: Boolean) {
        _animateBottomAreaDozingTransitions.value = animate
    }
@@ -628,6 +636,10 @@ constructor(
        _isQuickSettingsVisible.value = isVisible
    }

    override fun setIsActiveDreamLockscreenHosted(isLockscreenHosted: Boolean) {
        _isActiveDreamLockscreenHosted.value = isLockscreenHosted
    }

    private fun statusBarStateIntToObject(value: Int): StatusBarState {
        return when (value) {
            0 -> StatusBarState.SHADE
+6 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ constructor(
    val isDreaming: Flow<Boolean> = repository.isDreaming
    /** Whether the system is dreaming with an overlay active */
    val isDreamingWithOverlay: Flow<Boolean> = repository.isDreamingWithOverlay
    /** Whether the system is dreaming and the active dream is hosted in lockscreen */
    val isActiveDreamLockscreenHosted: Flow<Boolean> = repository.isActiveDreamLockscreenHosted
    /** Event for when the camera gesture is detected */
    val onCameraLaunchDetected: Flow<CameraLaunchSourceModel> = conflatedCallbackFlow {
        val callback =
@@ -198,6 +200,10 @@ constructor(
        }
    }

    fun setIsActiveDreamLockscreenHosted(isLockscreenHosted: Boolean) {
        repository.setIsActiveDreamLockscreenHosted(isLockscreenHosted)
    }

    /** Sets whether quick settings or quick-quick settings is visible. */
    fun setQuickSettingsVisible(isVisible: Boolean) {
        repository.setQuickSettingsVisible(isVisible)
+10 −0
Original line number Diff line number Diff line
@@ -298,6 +298,16 @@ class KeyguardRepositoryImplTest : SysuiTestCase() {
            verify(statusBarStateController).removeCallback(captor.value)
        }

    @Test
    fun isActiveDreamLockscreenHosted() =
        testScope.runTest {
            underTest.setIsActiveDreamLockscreenHosted(true)
            assertThat(underTest.isActiveDreamLockscreenHosted.value).isEqualTo(true)

            underTest.setIsActiveDreamLockscreenHosted(false)
            assertThat(underTest.isActiveDreamLockscreenHosted.value).isEqualTo(false)
        }

    @Test
    fun wakefulness() =
        testScope.runTest {
+7 −0
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@ class FakeKeyguardRepository : KeyguardRepository {
    private val _isDreamingWithOverlay = MutableStateFlow(false)
    override val isDreamingWithOverlay: Flow<Boolean> = _isDreamingWithOverlay

    private val _isActiveDreamLockscreenHosted = MutableStateFlow(false)
    override val isActiveDreamLockscreenHosted: StateFlow<Boolean> = _isActiveDreamLockscreenHosted

    private val _dozeAmount = MutableStateFlow(0f)
    override val linearDozeAmount: Flow<Float> = _dozeAmount

@@ -155,6 +158,10 @@ class FakeKeyguardRepository : KeyguardRepository {
        _isDreamingWithOverlay.value = isDreaming
    }

    override fun setIsActiveDreamLockscreenHosted(isLockscreenHosted: Boolean) {
        _isActiveDreamLockscreenHosted.value = isLockscreenHosted
    }

    fun setDozeAmount(dozeAmount: Float) {
        _dozeAmount.value = dozeAmount
    }