Adds snapshot function for isKeyguardShowing.
This complements the already-existing flow version of the same property and is needed by downstream CLs on this chain. Bug: 246631653 Test: test updated Change-Id: Ie37246d4b0614e477338dbcaad7e6aab0b7b0fa4
This commit is contained in:
@@ -85,6 +85,15 @@ interface KeyguardRepository {
|
||||
*/
|
||||
val dozeAmount: Flow<Float>
|
||||
|
||||
/**
|
||||
* Returns `true` if the keyguard is showing; `false` otherwise.
|
||||
*
|
||||
* Note: this is also `true` when the lock-screen is occluded with an `Activity` "above" it in
|
||||
* the z-order (which is not really above the system UI window, but rather - the lock-screen
|
||||
* becomes invisible to reveal the "occluding activity").
|
||||
*/
|
||||
fun isKeyguardShowing(): Boolean
|
||||
|
||||
/** Sets whether the bottom area UI should animate the transition out of doze state. */
|
||||
fun setAnimateDozingTransitions(animate: Boolean)
|
||||
|
||||
@@ -103,7 +112,7 @@ class KeyguardRepositoryImpl
|
||||
@Inject
|
||||
constructor(
|
||||
statusBarStateController: StatusBarStateController,
|
||||
keyguardStateController: KeyguardStateController,
|
||||
private val keyguardStateController: KeyguardStateController,
|
||||
dozeHost: DozeHost,
|
||||
) : KeyguardRepository {
|
||||
private val _animateBottomAreaDozingTransitions = MutableStateFlow(false)
|
||||
@@ -168,6 +177,10 @@ constructor(
|
||||
awaitClose { statusBarStateController.removeCallback(callback) }
|
||||
}
|
||||
|
||||
override fun isKeyguardShowing(): Boolean {
|
||||
return keyguardStateController.isShowing
|
||||
}
|
||||
|
||||
override fun setAnimateDozingTransitions(animate: Boolean) {
|
||||
_animateBottomAreaDozingTransitions.value = animate
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
class KeyguardInteractor
|
||||
@Inject
|
||||
constructor(
|
||||
repository: KeyguardRepository,
|
||||
private val repository: KeyguardRepository,
|
||||
) {
|
||||
/**
|
||||
* The amount of doze the system is in, where `1.0` is fully dozing and `0.0` is not dozing at
|
||||
@@ -40,4 +40,8 @@ constructor(
|
||||
val isDozing: Flow<Boolean> = repository.isDozing
|
||||
/** Whether the keyguard is showing ot not. */
|
||||
val isKeyguardShowing: Flow<Boolean> = repository.isKeyguardShowing
|
||||
|
||||
fun isKeyguardShowing(): Boolean {
|
||||
return repository.isKeyguardShowing()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ class KeyguardRepositoryImplTest : SysuiTestCase() {
|
||||
val job = underTest.isKeyguardShowing.onEach { latest = it }.launchIn(this)
|
||||
|
||||
assertThat(latest).isFalse()
|
||||
assertThat(underTest.isKeyguardShowing()).isFalse()
|
||||
|
||||
val captor = argumentCaptor<KeyguardStateController.Callback>()
|
||||
verify(keyguardStateController).addCallback(captor.capture())
|
||||
@@ -123,10 +124,12 @@ class KeyguardRepositoryImplTest : SysuiTestCase() {
|
||||
whenever(keyguardStateController.isShowing).thenReturn(true)
|
||||
captor.value.onKeyguardShowingChanged()
|
||||
assertThat(latest).isTrue()
|
||||
assertThat(underTest.isKeyguardShowing()).isTrue()
|
||||
|
||||
whenever(keyguardStateController.isShowing).thenReturn(false)
|
||||
captor.value.onKeyguardShowingChanged()
|
||||
assertThat(latest).isFalse()
|
||||
assertThat(underTest.isKeyguardShowing()).isFalse()
|
||||
|
||||
job.cancel()
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ class FakeKeyguardRepository : KeyguardRepository {
|
||||
private val _dozeAmount = MutableStateFlow(0f)
|
||||
override val dozeAmount: Flow<Float> = _dozeAmount
|
||||
|
||||
override fun isKeyguardShowing(): Boolean {
|
||||
return _isKeyguardShowing.value
|
||||
}
|
||||
|
||||
override fun setAnimateDozingTransitions(animate: Boolean) {
|
||||
_animateBottomAreaDozingTransitions.tryEmit(animate)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user