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

Commit fadd782b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Show AOD device entry icon with other LS views" into main

parents 3233ae9e 5ac6ec9d
Loading
Loading
Loading
Loading
+16 −44
Original line number Diff line number Diff line
@@ -71,10 +71,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun isLongPressEnabled_udfpsRunning() =
        testScope.runTest {
            val isLongPressEnabled by collectLastValue(underTest.isLongPressEnabled)
            setUpState(
                isUdfpsSupported = true,
                isUdfpsRunning = true,
            )
            setUpState(isUdfpsSupported = true, isUdfpsRunning = true)
            assertThat(isLongPressEnabled).isFalse()
        }

@@ -82,10 +79,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun isLongPressEnabled_unlocked() =
        testScope.runTest {
            val isLongPressEnabled by collectLastValue(underTest.isLongPressEnabled)
            setUpState(
                isUdfpsSupported = true,
                isLockscreenDismissible = true,
            )
            setUpState(isUdfpsSupported = true, hasTrust = true)
            assertThat(isLongPressEnabled).isTrue()
        }

@@ -122,10 +116,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun iconType_fingerprint() =
        testScope.runTest {
            val iconType by collectLastValue(underTest.iconType)
            setUpState(
                isUdfpsSupported = true,
                isUdfpsRunning = true,
            )
            setUpState(isUdfpsSupported = true, isUdfpsRunning = true)
            assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.FINGERPRINT)
        }

@@ -143,7 +134,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun iconType_unlocked() =
        testScope.runTest {
            val iconType by collectLastValue(underTest.iconType)
            setUpState(isLockscreenDismissible = true)
            setUpState(hasTrust = true)
            assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.UNLOCK)
        }

@@ -152,11 +143,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun iconType_none() =
        testScope.runTest {
            val iconType by collectLastValue(underTest.iconType)
            setUpState(
                isUdfpsSupported = true,
                isUdfpsRunning = true,
                isLockscreenDismissible = true,
            )
            setUpState(isUdfpsSupported = true, isUdfpsRunning = true, hasTrust = true)
            assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.NONE)
        }

@@ -165,10 +152,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun iconType_fingerprint_withSceneContainer() =
        testScope.runTest {
            val iconType by collectLastValue(underTest.iconType)
            setUpState(
                isUdfpsSupported = true,
                isUdfpsRunning = true,
            )
            setUpState(isUdfpsSupported = true, isUdfpsRunning = true)
            assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.FINGERPRINT)
        }

@@ -186,9 +170,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun iconType_unlocked_withSceneContainer() =
        testScope.runTest {
            val iconType by collectLastValue(underTest.iconType)
            setUpState(
                isLockscreenDismissible = true,
            )
            setUpState(hasTrust = true)
            assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.UNLOCK)
        }

@@ -197,11 +179,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    fun iconType_none_withSceneContainer() =
        testScope.runTest {
            val iconType by collectLastValue(underTest.iconType)
            setUpState(
                isUdfpsSupported = true,
                isUdfpsRunning = true,
                isLockscreenDismissible = true,
            )
            setUpState(isUdfpsSupported = true, isUdfpsRunning = true, hasTrust = true)
            assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.NONE)
        }

@@ -226,10 +204,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
                .isEqualTo(DeviceEntryIconView.AccessibilityHintType.BOUNCER)

            // udfps running
            setUpState(
                isUdfpsSupported = true,
                isUdfpsRunning = true,
            )
            setUpState(isUdfpsSupported = true, isUdfpsRunning = true)

            assertThat(accessibilityDelegateHint)
                .isEqualTo(DeviceEntryIconView.AccessibilityHintType.BOUNCER)
@@ -248,10 +223,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
            kosmos.fakeAccessibilityRepository.isEnabled.value = true

            // interactive unlock icon
            setUpState(
                isUdfpsSupported = true,
                isLockscreenDismissible = true,
            )
            setUpState(isUdfpsSupported = true, hasTrust = true)

            assertThat(accessibilityDelegateHint)
                .isEqualTo(DeviceEntryIconView.AccessibilityHintType.ENTER)
@@ -264,7 +236,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
    private suspend fun TestScope.setUpState(
        isUdfpsSupported: Boolean = false,
        isUdfpsRunning: Boolean = false,
        isLockscreenDismissible: Boolean = false,
        hasTrust: Boolean = false,
    ) {
        if (isUdfpsSupported) {
            fingerprintPropertyRepository.supportsUdfps()
@@ -275,17 +247,17 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
        } else {
            fingerprintAuthRepository.setIsRunning(false)
        }
        if (isLockscreenDismissible) {
            setLockscreenDismissible()
        if (hasTrust) {
            setHasTrust()
        } else {
            if (!SceneContainerFlag.isEnabled) {
                keyguardRepository.setKeyguardDismissible(false)
                keyguardRepository.setHasTrust(false)
            }
        }
        runCurrent()
    }

    private suspend fun TestScope.setLockscreenDismissible() {
    private suspend fun TestScope.setHasTrust() {
        if (SceneContainerFlag.isEnabled) {
            // Need to set up a collection for the authentication to be propagated.
            val unused by collectLastValue(kosmos.deviceUnlockedInteractor.deviceUnlockStatus)
@@ -297,7 +269,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() {
                )
                .isEqualTo(AuthenticationResult.SUCCEEDED)
        } else {
            keyguardRepository.setKeyguardDismissible(true)
            keyguardRepository.setHasTrust(true)
        }
        advanceTimeBy(UNLOCKED_DELAY_MS * 2) // wait for unlocked delay
    }
+6 −9
Original line number Diff line number Diff line
@@ -227,20 +227,17 @@ class GoneToAodTransitionViewModelTest : SysuiTestCase() {
            val deviceEntryParentViewAlpha by collectLastValue(underTest.deviceEntryParentViewAlpha)
            runCurrent()

            // animation doesn't start until the end
            // immediately 1f
            repository.sendTransitionStep(step(0f, TransitionState.STARTED))
            assertThat(deviceEntryParentViewAlpha).isEqualTo(0f)
            assertThat(deviceEntryParentViewAlpha).isEqualTo(1f)

            repository.sendTransitionStep(step(0.5f))
            assertThat(deviceEntryParentViewAlpha).isEqualTo(0f)
            repository.sendTransitionStep(step(0.4f))
            assertThat(deviceEntryParentViewAlpha).isEqualTo(1f)

            repository.sendTransitionStep(step(.95f))
            assertThat(deviceEntryParentViewAlpha).isIn(Range.closed(.01f, 1f))
            repository.sendTransitionStep(step(.85f))
            assertThat(deviceEntryParentViewAlpha).isEqualTo(1f)

            repository.sendTransitionStep(step(1f))
            assertThat(deviceEntryParentViewAlpha).isIn(Range.closed(.99f, 1f))

            repository.sendTransitionStep(step(1f, TransitionState.FINISHED))
            assertThat(deviceEntryParentViewAlpha).isEqualTo(1f)
        }

+1 −1
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ constructor(
        if (SceneContainerFlag.isEnabled) {
                deviceEntryInteractor.isUnlocked
            } else {
                keyguardInteractor.isKeyguardDismissible
                keyguardInteractor.hasTrust
            }
            .flatMapLatest { isUnlocked ->
                if (!isUnlocked) {
+1 −9
Original line number Diff line number Diff line
@@ -108,15 +108,7 @@ constructor(
    override val deviceEntryParentViewAlpha: Flow<Float> =
        deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest { udfpsEnrolled ->
            if (udfpsEnrolled) {
                // fade in at the end of the transition to give time for FP to start running
                // and avoid a flicker of the unlocked icon
                transitionAnimation.sharedFlow(
                    startTime = 1100.milliseconds,
                    duration = 200.milliseconds,
                    onStep = { it },
                    onCancel = { 1f },
                    onFinish = { 1f },
                )
                transitionAnimation.immediatelyTransitionTo(1f)
            } else {
                emptyFlow()
            }