Merge "Hide the alternate bouncer on device unlocked" into tm-qpr-dev am: 8eb543ff6a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22124912

Change-Id: I8016f5349b4ec2863f109aecba16dc609e262a0d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Beverly Tai
2023-03-20 17:01:23 +00:00
committed by Automerger Merge Worker
2 changed files with 55 additions and 0 deletions

View File

@@ -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

View File

@@ -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)