Merge "Hide the alternate bouncer on device unlocked" into tm-qpr-dev
This commit is contained in:
@@ -48,6 +48,17 @@ constructor(
|
||||
|
||||
val isVisible: Flow<Boolean> = bouncerRepository.alternateBouncerVisible
|
||||
|
||||
private val keyguardStateControllerCallback: KeyguardStateController.Callback =
|
||||
object : KeyguardStateController.Callback {
|
||||
override fun onUnlockedChanged() {
|
||||
maybeHide()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
keyguardStateController.addCallback(keyguardStateControllerCallback)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the correct bouncer states to show the alternate bouncer if it can show.
|
||||
*
|
||||
@@ -127,6 +138,12 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun maybeHide() {
|
||||
if (isVisibleState() && !canShowAlternateBouncerForFingerprint()) {
|
||||
hide()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MIN_VISIBILITY_DURATION_UNTIL_TOUCHES_DISMISS_ALTERNATE_BOUNCER_MS = 200L
|
||||
private const val NOT_VISIBLE = -1L
|
||||
|
||||
@@ -39,8 +39,10 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@@ -169,6 +171,42 @@ class AlternateBouncerInteractorTest : SysuiTestCase() {
|
||||
assertFalse(bouncerRepository.alternateBouncerVisible.value)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onUnlockedIsFalse_doesNotHide() {
|
||||
// GIVEN alternate bouncer is showing
|
||||
bouncerRepository.setAlternateVisible(true)
|
||||
|
||||
val keyguardStateControllerCallbackCaptor =
|
||||
ArgumentCaptor.forClass(KeyguardStateController.Callback::class.java)
|
||||
verify(keyguardStateController).addCallback(keyguardStateControllerCallbackCaptor.capture())
|
||||
|
||||
// WHEN isUnlocked=false
|
||||
givenCanShowAlternateBouncer()
|
||||
whenever(keyguardStateController.isUnlocked).thenReturn(false)
|
||||
keyguardStateControllerCallbackCaptor.value.onUnlockedChanged()
|
||||
|
||||
// THEN the alternate bouncer is still visible
|
||||
assertTrue(bouncerRepository.alternateBouncerVisible.value)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onUnlockedChangedIsTrue_hide() {
|
||||
// GIVEN alternate bouncer is showing
|
||||
bouncerRepository.setAlternateVisible(true)
|
||||
|
||||
val keyguardStateControllerCallbackCaptor =
|
||||
ArgumentCaptor.forClass(KeyguardStateController.Callback::class.java)
|
||||
verify(keyguardStateController).addCallback(keyguardStateControllerCallbackCaptor.capture())
|
||||
|
||||
// WHEN isUnlocked=true
|
||||
givenCanShowAlternateBouncer()
|
||||
whenever(keyguardStateController.isUnlocked).thenReturn(true)
|
||||
keyguardStateControllerCallbackCaptor.value.onUnlockedChanged()
|
||||
|
||||
// THEN the alternate bouncer is hidden
|
||||
assertFalse(bouncerRepository.alternateBouncerVisible.value)
|
||||
}
|
||||
|
||||
private fun givenCanShowAlternateBouncer() {
|
||||
bouncerRepository.setAlternateBouncerUIAvailable(true)
|
||||
biometricSettingsRepository.setFingerprintEnrolled(true)
|
||||
|
||||
Reference in New Issue
Block a user