Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt +8 −19 Original line number Diff line number Diff line Loading @@ -333,27 +333,16 @@ class KeyguardRepositoryImplTest : SysuiTestCase() { } @Test fun isDreamingFromKeyguardUpdateMonitor() = TestScope(mainDispatcher).runTest { whenever(keyguardUpdateMonitor.isDreaming()).thenReturn(false) var latest: Boolean? = null val job = underTest.isDreaming.onEach { latest = it }.launchIn(this) runCurrent() assertThat(latest).isFalse() val captor = argumentCaptor<KeyguardUpdateMonitorCallback>() verify(keyguardUpdateMonitor).registerCallback(captor.capture()) captor.value.onDreamingStateChanged(true) runCurrent() assertThat(latest).isTrue() fun isDreaming() = testScope.runTest { val isDreaming by collectLastValue(underTest.isDreaming) assertThat(isDreaming).isFalse() captor.value.onDreamingStateChanged(false) runCurrent() assertThat(latest).isFalse() underTest.setDreaming(true) assertThat(isDreaming).isTrue() job.cancel() underTest.setDreaming(false) assertThat(isDreaming).isFalse() } @Test Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +6 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import com.android.systemui.dagger.qualifiers.Application; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.domain.interactor.KeyguardEnabledInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier; import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindViewBinder; import com.android.systemui.keyguard.ui.binder.WindowManagerLockscreenVisibilityViewBinder; Loading Loading @@ -118,6 +119,7 @@ public class KeyguardService extends Service { private final ShellTransitions mShellTransitions; private final DisplayTracker mDisplayTracker; private final PowerInteractor mPowerInteractor; private final KeyguardInteractor mKeyguardInteractor; private final Lazy<SceneInteractor> mSceneInteractorLazy; private final Executor mMainExecutor; Loading Loading @@ -338,6 +340,7 @@ public class KeyguardService extends Service { WindowManagerOcclusionManager windowManagerOcclusionManager, Lazy<SceneInteractor> sceneInteractorLazy, @Main Executor mainExecutor, KeyguardInteractor keyguardInteractor, KeyguardEnabledInteractor keyguardEnabledInteractor) { super(); mKeyguardViewMediator = keyguardViewMediator; Loading @@ -347,6 +350,7 @@ public class KeyguardService extends Service { mDisplayTracker = displayTracker; mFlags = featureFlags; mPowerInteractor = powerInteractor; mKeyguardInteractor = keyguardInteractor; mSceneInteractorLazy = sceneInteractorLazy; mMainExecutor = mainExecutor; Loading Loading @@ -474,6 +478,7 @@ public class KeyguardService extends Service { public void onDreamingStarted() { trace("onDreamingStarted"); checkPermission(); mKeyguardInteractor.setDreaming(true); mKeyguardViewMediator.onDreamingStarted(); } Loading @@ -481,6 +486,7 @@ public class KeyguardService extends Service { public void onDreamingStopped() { trace("onDreamingStopped"); checkPermission(); mKeyguardInteractor.setDreaming(false); mKeyguardViewMediator.onDreamingStopped(); } Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +9 −20 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ interface KeyguardRepository { * Dozing/AOD is a specific type of dream, but it is also possible for other non-systemui dreams * to be active, such as screensavers. */ val isDreaming: Flow<Boolean> val isDreaming: MutableStateFlow<Boolean> /** Observable for whether the device is dreaming with an overlay, see [DreamOverlayService] */ val isDreamingWithOverlay: Flow<Boolean> Loading Loading @@ -250,6 +250,9 @@ interface KeyguardRepository { /** Sets the current amount of alpha that should be used for rendering the keyguard. */ fun setKeyguardAlpha(alpha: Float) /** Whether the device is actively dreaming */ fun setDreaming(isDreaming: Boolean) /** * Returns whether the keyguard bottom area should be constrained to the top of the lock icon */ Loading Loading @@ -509,25 +512,7 @@ constructor( } .distinctUntilChanged() override val isDreaming: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardUpdateMonitorCallback() { override fun onDreamingStateChanged(isDreaming: Boolean) { trySendWithFailureLogging(isDreaming, TAG, "updated isDreaming") } } keyguardUpdateMonitor.registerCallback(callback) trySendWithFailureLogging( keyguardUpdateMonitor.isDreaming, TAG, "initial isDreaming", ) awaitClose { keyguardUpdateMonitor.removeCallback(callback) } } .flowOn(mainDispatcher) .distinctUntilChanged() override val isDreaming: MutableStateFlow<Boolean> = MutableStateFlow(false) override val linearDozeAmount: Flow<Float> = conflatedCallbackFlow { val callback = Loading Loading @@ -674,6 +659,10 @@ constructor( _keyguardAlpha.value = alpha } override fun setDreaming(isDreaming: Boolean) { this.isDreaming.value = isDreaming } override fun isUdfpsSupported(): Boolean = keyguardUpdateMonitor.isUdfpsSupported override fun setQuickSettingsVisible(isVisible: Boolean) { Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,10 @@ constructor( repository.topClippingBounds.value = top } fun setDreaming(isDreaming: Boolean) { repository.setDreaming(isDreaming) } /** Temporary shim, until [KeyguardWmStateRefactor] is enabled */ fun showKeyguard() { fromGoneTransitionInteractor.get().showKeyguard() Loading packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt +2 −2 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository { override val isAodAvailable: StateFlow<Boolean> = _isAodAvailable private val _isDreaming = MutableStateFlow(false) override val isDreaming: Flow<Boolean> = _isDreaming override val isDreaming: MutableStateFlow<Boolean> = _isDreaming private val _isDreamingWithOverlay = MutableStateFlow(false) override val isDreamingWithOverlay: Flow<Boolean> = _isDreamingWithOverlay Loading Loading @@ -204,7 +204,7 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository { _isAodAvailable.value = value } fun setDreaming(isDreaming: Boolean) { override fun setDreaming(isDreaming: Boolean) { _isDreaming.value = isDreaming } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt +8 −19 Original line number Diff line number Diff line Loading @@ -333,27 +333,16 @@ class KeyguardRepositoryImplTest : SysuiTestCase() { } @Test fun isDreamingFromKeyguardUpdateMonitor() = TestScope(mainDispatcher).runTest { whenever(keyguardUpdateMonitor.isDreaming()).thenReturn(false) var latest: Boolean? = null val job = underTest.isDreaming.onEach { latest = it }.launchIn(this) runCurrent() assertThat(latest).isFalse() val captor = argumentCaptor<KeyguardUpdateMonitorCallback>() verify(keyguardUpdateMonitor).registerCallback(captor.capture()) captor.value.onDreamingStateChanged(true) runCurrent() assertThat(latest).isTrue() fun isDreaming() = testScope.runTest { val isDreaming by collectLastValue(underTest.isDreaming) assertThat(isDreaming).isFalse() captor.value.onDreamingStateChanged(false) runCurrent() assertThat(latest).isFalse() underTest.setDreaming(true) assertThat(isDreaming).isTrue() job.cancel() underTest.setDreaming(false) assertThat(isDreaming).isFalse() } @Test Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +6 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import com.android.systemui.dagger.qualifiers.Application; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.domain.interactor.KeyguardEnabledInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier; import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindViewBinder; import com.android.systemui.keyguard.ui.binder.WindowManagerLockscreenVisibilityViewBinder; Loading Loading @@ -118,6 +119,7 @@ public class KeyguardService extends Service { private final ShellTransitions mShellTransitions; private final DisplayTracker mDisplayTracker; private final PowerInteractor mPowerInteractor; private final KeyguardInteractor mKeyguardInteractor; private final Lazy<SceneInteractor> mSceneInteractorLazy; private final Executor mMainExecutor; Loading Loading @@ -338,6 +340,7 @@ public class KeyguardService extends Service { WindowManagerOcclusionManager windowManagerOcclusionManager, Lazy<SceneInteractor> sceneInteractorLazy, @Main Executor mainExecutor, KeyguardInteractor keyguardInteractor, KeyguardEnabledInteractor keyguardEnabledInteractor) { super(); mKeyguardViewMediator = keyguardViewMediator; Loading @@ -347,6 +350,7 @@ public class KeyguardService extends Service { mDisplayTracker = displayTracker; mFlags = featureFlags; mPowerInteractor = powerInteractor; mKeyguardInteractor = keyguardInteractor; mSceneInteractorLazy = sceneInteractorLazy; mMainExecutor = mainExecutor; Loading Loading @@ -474,6 +478,7 @@ public class KeyguardService extends Service { public void onDreamingStarted() { trace("onDreamingStarted"); checkPermission(); mKeyguardInteractor.setDreaming(true); mKeyguardViewMediator.onDreamingStarted(); } Loading @@ -481,6 +486,7 @@ public class KeyguardService extends Service { public void onDreamingStopped() { trace("onDreamingStopped"); checkPermission(); mKeyguardInteractor.setDreaming(false); mKeyguardViewMediator.onDreamingStopped(); } Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +9 −20 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ interface KeyguardRepository { * Dozing/AOD is a specific type of dream, but it is also possible for other non-systemui dreams * to be active, such as screensavers. */ val isDreaming: Flow<Boolean> val isDreaming: MutableStateFlow<Boolean> /** Observable for whether the device is dreaming with an overlay, see [DreamOverlayService] */ val isDreamingWithOverlay: Flow<Boolean> Loading Loading @@ -250,6 +250,9 @@ interface KeyguardRepository { /** Sets the current amount of alpha that should be used for rendering the keyguard. */ fun setKeyguardAlpha(alpha: Float) /** Whether the device is actively dreaming */ fun setDreaming(isDreaming: Boolean) /** * Returns whether the keyguard bottom area should be constrained to the top of the lock icon */ Loading Loading @@ -509,25 +512,7 @@ constructor( } .distinctUntilChanged() override val isDreaming: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardUpdateMonitorCallback() { override fun onDreamingStateChanged(isDreaming: Boolean) { trySendWithFailureLogging(isDreaming, TAG, "updated isDreaming") } } keyguardUpdateMonitor.registerCallback(callback) trySendWithFailureLogging( keyguardUpdateMonitor.isDreaming, TAG, "initial isDreaming", ) awaitClose { keyguardUpdateMonitor.removeCallback(callback) } } .flowOn(mainDispatcher) .distinctUntilChanged() override val isDreaming: MutableStateFlow<Boolean> = MutableStateFlow(false) override val linearDozeAmount: Flow<Float> = conflatedCallbackFlow { val callback = Loading Loading @@ -674,6 +659,10 @@ constructor( _keyguardAlpha.value = alpha } override fun setDreaming(isDreaming: Boolean) { this.isDreaming.value = isDreaming } override fun isUdfpsSupported(): Boolean = keyguardUpdateMonitor.isUdfpsSupported override fun setQuickSettingsVisible(isVisible: Boolean) { Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,10 @@ constructor( repository.topClippingBounds.value = top } fun setDreaming(isDreaming: Boolean) { repository.setDreaming(isDreaming) } /** Temporary shim, until [KeyguardWmStateRefactor] is enabled */ fun showKeyguard() { fromGoneTransitionInteractor.get().showKeyguard() Loading
packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt +2 −2 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository { override val isAodAvailable: StateFlow<Boolean> = _isAodAvailable private val _isDreaming = MutableStateFlow(false) override val isDreaming: Flow<Boolean> = _isDreaming override val isDreaming: MutableStateFlow<Boolean> = _isDreaming private val _isDreamingWithOverlay = MutableStateFlow(false) override val isDreamingWithOverlay: Flow<Boolean> = _isDreamingWithOverlay Loading Loading @@ -204,7 +204,7 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository { _isAodAvailable.value = value } fun setDreaming(isDreaming: Boolean) { override fun setDreaming(isDreaming: Boolean) { _isDreaming.value = isDreaming } Loading