Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4554f215 authored by Beverly's avatar Beverly
Browse files

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
parent fd9ac7f4
Loading
Loading
Loading
Loading
+26 −6
Original line number Diff line number Diff line
@@ -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,21 +177,35 @@ 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) {
                DeviceEntryIconView.IconType.UNLOCK
            } else {
            if (isListeningForUdfps) {
                DeviceEntryIconView.IconType.FINGERPRINT
            } else if (isUnlocked) {
                DeviceEntryIconView.IconType.UNLOCK
            } else {
                DeviceEntryIconView.IconType.LOCK
            }
        }
        }
    val isLongPressEnabled: Flow<Boolean> =
        combine(
            iconType,
@@ -229,6 +245,10 @@ constructor(
                DeviceEntryIconView.AccessibilityHintType.NONE
        }
    }

    companion object {
        const val UNLOCKED_DELAY_MS = 50L
    }
}

data class BurnInOffsets(
+2 −4
Original line number Diff line number Diff line
@@ -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()
        }