summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Beverly <beverlyt@google.com> 2024-01-26 19:25:28 +0000
committer Beverly <beverlyt@google.com> 2024-02-02 14:53:53 +0000
commit4554f21546795967db58bf0eabbacadaf97ca1dc (patch)
tree817bd2eb694a914ab9a3454fd0c6b62e9abbab21
parentfd9ac7f4508606287f45b9dbbba1867dd85cdf0b (diff)
Add small delay to animate device entry unlock icon
We don't want to flash the unlock icon when the user has unlocked the device and the device is transitioning to GONE. This is the easiest solution until keyguard transitions and unlocked states are better coordinated and potentially ordered. Test: manually confirmed (10/10 times) unlock icon doesn't show when authenticating with UDFPS Test: manually confirmed non-bypass face auth still updates UI to the unlocked icon as expected (and doesn't feel delayed) Test: atest UdfpsAccessibilityOverlayViewModelTest Fixes: 322512267 Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor DEVELOPMENT Change-Id: Icf11ded912563838b729711d554611ce01faf2da Change-Id: I912bf8bbc26d85f58822fde0db83fecbafd544a3
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModel.kt32
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt6
2 files changed, 28 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModel.kt
index 2320b0c8afe6..c9cf0c31a8fd 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModel.kt
@@ -34,9 +34,11 @@ import com.android.systemui.util.kotlin.sample
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
@@ -175,19 +177,33 @@ constructor(
flowOf(BurnInOffsets(x = 0, y = 0, progress = 0f))
}
}
+
+ private val isUnlocked: Flow<Boolean> =
+ deviceEntryInteractor.isUnlocked.flatMapLatest { isUnlocked ->
+ if (!isUnlocked) {
+ flowOf(false)
+ } else {
+ flow {
+ // delay in case device ends up transitioning away from the lock screen;
+ // we don't want to animate to the unlocked icon and just let the
+ // icon fade with the transition to GONE
+ delay(UNLOCKED_DELAY_MS)
+ emit(true)
+ }
+ }
+ }
+
val iconType: Flow<DeviceEntryIconView.IconType> =
combine(
deviceEntryUdfpsInteractor.isListeningForUdfps,
keyguardInteractor.isKeyguardDismissible,
) { isListeningForUdfps, isUnlocked ->
- if (isUnlocked) {
+ if (isListeningForUdfps) {
+ DeviceEntryIconView.IconType.FINGERPRINT
+ } else if (isUnlocked) {
DeviceEntryIconView.IconType.UNLOCK
} else {
- if (isListeningForUdfps) {
- DeviceEntryIconView.IconType.FINGERPRINT
- } else {
- DeviceEntryIconView.IconType.LOCK
- }
+ DeviceEntryIconView.IconType.LOCK
}
}
val isLongPressEnabled: Flow<Boolean> =
@@ -229,6 +245,10 @@ constructor(
DeviceEntryIconView.AccessibilityHintType.NONE
}
}
+
+ companion object {
+ const val UNLOCKED_DELAY_MS = 50L
+ }
}
data class BurnInOffsets(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt
index 92a508d0daed..e97edcbdc68a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt
@@ -103,13 +103,11 @@ class UdfpsAccessibilityOverlayViewModelTest : SysuiTestCase() {
)
assertThat(visible).isFalse()
}
-
- @Test
- fun keyguardDismissible_overlayNotVisible() =
+ fun fpNotRunning_overlayNotVisible() =
testScope.runTest {
val visible by collectLastValue(underTest.visible)
setupVisibleStateOnLockscreen()
- keyguardRepository.setKeyguardDismissible(true)
+ deviceEntryFingerprintAuthRepository.setIsRunning(false)
assertThat(visible).isFalse()
}