diff options
| author | 2023-03-20 16:57:36 +0000 | |
|---|---|---|
| committer | 2023-03-20 16:57:36 +0000 | |
| commit | 8eb543ff6a304c8b9652b97bf0848056e1ceec45 (patch) | |
| tree | 6af9e40adfa9be9ea9d1859c4c9a9024a1150635 | |
| parent | 2639c3b3169a38e44161d4f9e9badfed3a48360a (diff) | |
| parent | 356c90dd454bb8070aee23e6491abe1800647e09 (diff) | |
Merge "Hide the alternate bouncer on device unlocked" into tm-qpr-dev
2 files changed, 55 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractor.kt index eae40d61cdb6..e1702c5d61c4 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractor.kt @@ -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 diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractorTest.kt index 1365132d6dac..2060e3d5d3bd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/AlternateBouncerInteractorTest.kt @@ -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) |