diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt index edc0b45d27f29..e7704d6251689 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt @@ -121,6 +121,9 @@ interface KeyguardRepository { /** Observable for whether the device is dreaming with an overlay, see [DreamOverlayService] */ val isDreamingWithOverlay: Flow + /** Observable for device dreaming state and the active dream is hosted in lockscreen */ + val isActiveDreamLockscreenHosted: StateFlow + /** * 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 = _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 diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 228290a3203ff..7fae7522d981d 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -81,6 +81,8 @@ constructor( val isDreaming: Flow = repository.isDreaming /** Whether the system is dreaming with an overlay active */ val isDreamingWithOverlay: Flow = repository.isDreamingWithOverlay + /** Whether the system is dreaming and the active dream is hosted in lockscreen */ + val isActiveDreamLockscreenHosted: Flow = repository.isActiveDreamLockscreenHosted /** Event for when the camera gesture is detected */ val onCameraLaunchDetected: Flow = 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) diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt index 25573de1b12b8..e9f0d561371c0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt @@ -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 { diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt index f6cbb072495f4..eb2f71a9b951a 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt @@ -68,6 +68,9 @@ class FakeKeyguardRepository : KeyguardRepository { private val _isDreamingWithOverlay = MutableStateFlow(false) override val isDreamingWithOverlay: Flow = _isDreamingWithOverlay + private val _isActiveDreamLockscreenHosted = MutableStateFlow(false) + override val isActiveDreamLockscreenHosted: StateFlow = _isActiveDreamLockscreenHosted + private val _dozeAmount = MutableStateFlow(0f) override val linearDozeAmount: Flow = _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 }