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

Commit bbdb9bc9 authored by Beverly's avatar Beverly
Browse files

DeviceEntryIconViewModel uses isUnlocked flow with a slight delay

To avoid transitioning to the unlocked lock icon during the
LOCKSCREEN/AOD => GONE transition.

We also update deviceEntryInteractor.isUnlocked to use
keyguardInteractor.isKeyguardDismissible since the device
entry interactor should only be used when flexiglass
is enabled.

Test: atest DeviceEntryIconViewModelTest
Test: manually authenticate with UDFPS from LS,
and see there's no flash of the unlocked icon
Fixes: 323212430
Fixes: 322512267
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor STAGING

Change-Id: Id76c422816d439ab8c24c0a13f694f1db2b91efe
parent a168b9f3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ constructor(
        }

    private val isUnlocked: Flow<Boolean> =
        deviceEntryInteractor.isUnlocked.flatMapLatest { isUnlocked ->
        keyguardInteractor.isKeyguardDismissible.flatMapLatest { isUnlocked ->
            if (!isUnlocked) {
                flowOf(false)
            } else {
@@ -197,7 +197,7 @@ constructor(
    val iconType: Flow<DeviceEntryIconView.IconType> =
        combine(
            deviceEntryUdfpsInteractor.isListeningForUdfps,
            keyguardInteractor.isKeyguardDismissible,
            isUnlocked,
        ) { isListeningForUdfps, isUnlocked ->
            if (isListeningForUdfps) {
                DeviceEntryIconView.IconType.FINGERPRINT
+6 −0
Original line number Diff line number Diff line
@@ -27,11 +27,14 @@ import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.keyguardRepository
import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryIconViewModel.Companion.UNLOCKED_DELAY_MS
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlin.test.Test
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.runner.RunWith
@@ -71,7 +74,10 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun isLongPressEnabled_unlocked() =
        testScope.runTest {
            val isLongPressEnabled by collectLastValue(underTest.isLongPressEnabled)
            fingerprintPropertyRepository.supportsUdfps()
            keyguardRepository.setKeyguardDismissible(true)
            advanceTimeBy(UNLOCKED_DELAY_MS * 2) // wait for unlocked delay
            runCurrent()
            assertThat(isLongPressEnabled).isTrue()
        }