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

Commit 1cb28c18 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge changes I37402933,I7b93ad4e into main

* changes:
  Upstream keyguard animation flow optimizations
  Remove reliance on bespoke transition methods
parents 1ea3e82a 9df88782
Loading
Loading
Loading
Loading
+64 −62
Original line number Diff line number Diff line
@@ -55,9 +55,10 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
    val testScope = kosmos.testScope

    @Test
    fun transitionCollectorsReceivesOnlyAppropriateEvents() = runTest {
        val lockscreenToAodSteps by collectValues(underTest.lockscreenToAodTransition)
        val aodToLockscreenSteps by collectValues(underTest.aodToLockscreenTransition)
    fun transitionCollectorsReceivesOnlyAppropriateEvents() =
        testScope.runTest {
            val lockscreenToAodSteps by collectValues(underTest.transition(LOCKSCREEN, AOD))
            val aodToLockscreenSteps by collectValues(underTest.transition(AOD, LOCKSCREEN))

            val steps = mutableListOf<TransitionStep>()
            steps.add(TransitionStep(AOD, GONE, 0f, STARTED))
@@ -187,9 +188,9 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
        }

    @Test
    fun finishedKeyguardTransitionStepTests() = runTest {
    fun finishedKeyguardTransitionStepTests() =
        testScope.runTest {
            val finishedSteps by collectValues(underTest.finishedKeyguardTransitionStep)

            val steps = mutableListOf<TransitionStep>()

            steps.add(TransitionStep(LOCKSCREEN, AOD, 0f, STARTED))
@@ -211,7 +212,8 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
        }

    @Test
    fun startedKeyguardTransitionStepTests() = runTest {
    fun startedKeyguardTransitionStepTests() =
        testScope.runTest {
            val startedSteps by collectValues(underTest.startedKeyguardTransitionStep)

            val steps = mutableListOf<TransitionStep>()
+2 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.keyguard.ui

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE
import com.android.systemui.SysuiTestCase
@@ -35,10 +36,9 @@ import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@SmallTest
@RunWith(JUnit4::class)
@RunWith(AndroidJUnit4::class)
class KeyguardTransitionAnimationFlowTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val testScope = kosmos.testScope
+1 −22
Original line number Diff line number Diff line
@@ -49,9 +49,7 @@ class OccludedToLockscreenTransitionViewModelTest : SysuiTestCase() {
    val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
    val fingerprintPropertyRepository = kosmos.fingerprintPropertyRepository
    val configurationRepository = kosmos.fakeConfigurationRepository
    val underTest by lazy {
        kosmos.occludedToLockscreenTransitionViewModel
    }
    val underTest by lazy { kosmos.occludedToLockscreenTransitionViewModel }

    @Test
    fun lockscreenFadeIn() =
@@ -164,25 +162,6 @@ class OccludedToLockscreenTransitionViewModelTest : SysuiTestCase() {
            values.forEach { assertThat(it).isEqualTo(1f) }
        }

    @Test
    fun deviceEntryBackgroundView_noUdfpsEnrolled_noUpdates() =
        testScope.runTest {
            fingerprintPropertyRepository.supportsRearFps()
            biometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true)
            val values by collectValues(underTest.deviceEntryBackgroundViewAlpha)

            keyguardTransitionRepository.sendTransitionStep(step(0f, TransitionState.STARTED))
            keyguardTransitionRepository.sendTransitionStep(step(0.1f))
            keyguardTransitionRepository.sendTransitionStep(step(0.3f))
            keyguardTransitionRepository.sendTransitionStep(step(0.4f))
            keyguardTransitionRepository.sendTransitionStep(step(0.5f))
            keyguardTransitionRepository.sendTransitionStep(step(0.6f))
            keyguardTransitionRepository.sendTransitionStep(step(0.8f))
            keyguardTransitionRepository.sendTransitionStep(step(1f))

            assertThat(values).isEmpty() // no updates
        }

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
+10 −9
Original line number Diff line number Diff line
@@ -641,7 +641,6 @@ class ShadeInteractorImplTest : SysuiTestCase() {
                )
            )
            val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
            runCurrent()
            assertThat(isShadeTouchable).isFalse()
        }

@@ -668,13 +667,17 @@ class ShadeInteractorImplTest : SysuiTestCase() {
                )
            )
            val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
            runCurrent()
            assertThat(isShadeTouchable).isTrue()
        }

    @Test
    fun isShadeTouchable_isFalse_whenStartingToSleepAndNotControlScreenOff() =
        testScope.runTest {
            whenever(dozeParameters.shouldControlScreenOff()).thenReturn(false)
            val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
            // Assert the default condition is true
            assertThat(isShadeTouchable).isTrue()

            powerRepository.updateWakefulness(
                rawState = WakefulnessState.STARTING_TO_SLEEP,
                lastWakeReason = WakeSleepReason.POWER_BUTTON,
@@ -688,15 +691,17 @@ class ShadeInteractorImplTest : SysuiTestCase() {
                    transitionState = TransitionState.STARTED,
                )
            )
            whenever(dozeParameters.shouldControlScreenOff()).thenReturn(false)
            val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
            runCurrent()
            assertThat(isShadeTouchable).isFalse()
        }

    @Test
    fun isShadeTouchable_isTrue_whenStartingToSleepAndControlScreenOff() =
        testScope.runTest {
            whenever(dozeParameters.shouldControlScreenOff()).thenReturn(true)
            val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
            // Assert the default condition is true
            assertThat(isShadeTouchable).isTrue()

            powerRepository.updateWakefulness(
                rawState = WakefulnessState.STARTING_TO_SLEEP,
                lastWakeReason = WakeSleepReason.POWER_BUTTON,
@@ -710,9 +715,6 @@ class ShadeInteractorImplTest : SysuiTestCase() {
                    transitionState = TransitionState.STARTED,
                )
            )
            whenever(dozeParameters.shouldControlScreenOff()).thenReturn(true)
            val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
            runCurrent()
            assertThat(isShadeTouchable).isTrue()
        }

@@ -730,7 +732,6 @@ class ShadeInteractorImplTest : SysuiTestCase() {
                )
            )
            val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
            runCurrent()
            assertThat(isShadeTouchable).isTrue()
        }
}
+2 −1
Original line number Diff line number Diff line
@@ -282,7 +282,8 @@ open class UdfpsKeyguardViewControllerLegacy(
    @VisibleForTesting
    suspend fun listenForGoneToAodTransition(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor.goneToAodTransition.collect { transitionStep ->
            transitionInteractor.transition(KeyguardState.GONE, KeyguardState.AOD).collect {
                transitionStep ->
                view.onDozeAmountChanged(
                    transitionStep.value,
                    transitionStep.value,
Loading