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

Commit c125f55b authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge changes I912bf8bb,I8c50b8aa into main

* changes:
  Add small delay to animate device entry unlock icon
  Never use DeviceEntryInteractor unless behind the flexiglass flag
parents 2ad3ebcf 4554f215
Loading
Loading
Loading
Loading
+27 −7
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,
            deviceEntryInteractor.isUnlocked,
            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(
+4 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.deviceentry.data.ui.viewmodel.deviceEntryUdfpsAccess
import com.android.systemui.flags.Flags.FULL_SCREEN_USER_SWITCHER
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
@@ -51,6 +52,7 @@ class UdfpsAccessibilityOverlayViewModelTest : SysuiTestCase() {
        }
    private val deviceEntryIconTransition = kosmos.fakeDeviceEntryIconViewModelTransition
    private val testScope = kosmos.testScope
    private val keyguardRepository = kosmos.fakeKeyguardRepository
    private val accessibilityRepository = kosmos.fakeAccessibilityRepository
    private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
    private val fingerprintPropertyRepository = kosmos.fingerprintPropertyRepository
@@ -101,13 +103,11 @@ class UdfpsAccessibilityOverlayViewModelTest : SysuiTestCase() {
            )
            assertThat(visible).isFalse()
        }

    @Test
    fun deviceUnlocked_overlayNotVisible() =
    fun fpNotRunning_overlayNotVisible() =
        testScope.runTest {
            val visible by collectLastValue(underTest.visible)
            setupVisibleStateOnLockscreen()
            deviceEntryRepository.setUnlocked(true)
            deviceEntryFingerprintAuthRepository.setIsRunning(false)
            assertThat(visible).isFalse()
        }