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

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

Merge changes Iff931ed3,I4271d2c7,I9fda746f into main

* changes:
  Transform and consolidate transitionStepsToState callers
  Transform and consolidate transitionStepsFromState callers
  Consolidate dozeAmountTransition into transitionValue(AOD)
parents 931f8091 f0898b11
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ class UdfpsKeyguardViewLegacyControllerWithCoroutinesTest :

            job.cancel()
        }

    @Test
    fun fadeFromDialogSuggestedAlpha() =
        testScope.runTest {
@@ -511,9 +512,10 @@ class UdfpsKeyguardViewLegacyControllerWithCoroutinesTest :
        testScope.runTest {
            // GIVEN view is attached
            mController.onViewAttached()
            val job = mController.listenForLockscreenAodTransitions(this)
            runCurrent()
            Mockito.reset(mView)

            val job = mController.listenForLockscreenAodTransitions(this)
            // WHEN aod to lockscreen transition is cancelled
            transitionRepository.sendTransitionStep(
                TransitionStep(
@@ -537,7 +539,7 @@ class UdfpsKeyguardViewLegacyControllerWithCoroutinesTest :

            // THEN doze amount is updated to zero
            verify(mView)
                .onDozeAmountChanged(eq(0f), eq(0f), eq(UdfpsKeyguardViewLegacy.ANIMATION_NONE))
                .onDozeAmountChanged(eq(0f), eq(0f), eq(ANIMATION_BETWEEN_AOD_AND_LOCKSCREEN))
            job.cancel()
        }

@@ -546,9 +548,10 @@ class UdfpsKeyguardViewLegacyControllerWithCoroutinesTest :
        testScope.runTest {
            // GIVEN view is attached
            mController.onViewAttached()
            val job = mController.listenForLockscreenAodTransitions(this)
            runCurrent()
            Mockito.reset(mView)

            val job = mController.listenForLockscreenAodTransitions(this)
            // WHEN lockscreen to aod transition is cancelled
            transitionRepository.sendTransitionStep(
                TransitionStep(
+0 −62
Original line number Diff line number Diff line
@@ -124,68 +124,6 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
            assertThat(lockscreenToAodSteps).isEqualTo(steps.subList(5, 8))
        }

    @Test
    fun dozeAmountTransitionTest_AodToFromLockscreen() =
        testScope.runTest {
            val dozeAmountSteps by collectValues(underTest.dozeAmountTransition)

            val steps = mutableListOf<TransitionStep>()

            steps.add(TransitionStep(AOD, LOCKSCREEN, 0f, STARTED))
            steps.add(TransitionStep(AOD, LOCKSCREEN, 0.5f, RUNNING))
            steps.add(TransitionStep(AOD, LOCKSCREEN, 1f, FINISHED))
            steps.add(TransitionStep(LOCKSCREEN, AOD, 0f, STARTED))
            steps.add(TransitionStep(LOCKSCREEN, AOD, 0.8f, RUNNING))
            steps.add(TransitionStep(LOCKSCREEN, AOD, 0.9f, RUNNING))
            steps.add(TransitionStep(LOCKSCREEN, AOD, 1f, FINISHED))

            steps.forEach {
                repository.sendTransitionStep(it)
                runCurrent()
            }

            assertThat(dozeAmountSteps.subList(0, 3))
                .isEqualTo(
                    listOf(
                        steps[0].copy(value = 1f - steps[0].value),
                        steps[1].copy(value = 1f - steps[1].value),
                        steps[2].copy(value = 1f - steps[2].value),
                    )
                )
            assertThat(dozeAmountSteps.subList(3, 7)).isEqualTo(steps.subList(3, 7))
        }

    @Test
    fun dozeAmountTransitionTest_AodToFromGone() =
        testScope.runTest {
            val dozeAmountSteps by collectValues(underTest.dozeAmountTransition)

            val steps = mutableListOf<TransitionStep>()

            steps.add(TransitionStep(AOD, GONE, 0f, STARTED))
            steps.add(TransitionStep(AOD, GONE, 0.3f, RUNNING))
            steps.add(TransitionStep(AOD, GONE, 1f, FINISHED))
            steps.add(TransitionStep(GONE, AOD, 0f, STARTED))
            steps.add(TransitionStep(GONE, AOD, 0.1f, RUNNING))
            steps.add(TransitionStep(GONE, AOD, 0.3f, RUNNING))
            steps.add(TransitionStep(GONE, AOD, 1f, FINISHED))

            steps.forEach {
                repository.sendTransitionStep(it)
                runCurrent()
            }

            assertThat(dozeAmountSteps.subList(0, 3))
                .isEqualTo(
                    listOf(
                        steps[0].copy(value = 1f - steps[0].value),
                        steps[1].copy(value = 1f - steps[1].value),
                        steps[2].copy(value = 1f - steps[2].value),
                    )
                )
            assertThat(dozeAmountSteps.subList(3, 7)).isEqualTo(steps.subList(3, 7))
        }

    @Test
    fun finishedKeyguardStateTests() =
        testScope.runTest {
+7 −3
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ constructor(
        smallClockOnAttachStateChangeListener =
            object : OnAttachStateChangeListener {
                var pastVisibility: Int? = null

                override fun onViewAttachedToWindow(view: View) {
                    clock.events.onTimeFormatChanged(DateFormat.is24HourFormat(context))
                    // Match the asing for view.parent's layout classes.
@@ -213,6 +214,7 @@ constructor(
                override fun onViewAttachedToWindow(p0: View) {
                    clock.events.onTimeFormatChanged(DateFormat.is24HourFormat(context))
                }

                override fun onViewDetachedFromWindow(p0: View) {}
            }
        clock.largeClock.view.addOnAttachStateChangeListener(largeClockOnAttachStateChangeListener)
@@ -284,8 +286,10 @@ constructor(

    var smallRegionSampler: RegionSampler? = null
        private set

    var largeRegionSampler: RegionSampler? = null
        private set

    var smallTimeListener: TimeListener? = null
    var largeTimeListener: TimeListener? = null
    val shouldTimeListenerRun: Boolean
@@ -560,7 +564,7 @@ constructor(
    internal fun listenForAnyStateToAodTransition(scope: CoroutineScope): Job {
        return scope.launch {
            keyguardTransitionInteractor
                .transitionStepsToState(AOD)
                .transition(Edge.create(to = AOD))
                .filter { it.transitionState == TransitionState.STARTED }
                .filter { it.from != LOCKSCREEN }
                .collect { handleDoze(1f) }
@@ -571,7 +575,7 @@ constructor(
    internal fun listenForAnyStateToLockscreenTransition(scope: CoroutineScope): Job {
        return scope.launch {
            keyguardTransitionInteractor
                .transitionStepsToState(LOCKSCREEN)
                .transition(Edge.create(to = LOCKSCREEN))
                .filter { it.transitionState == TransitionState.STARTED }
                .filter { it.from != AOD }
                .collect { handleDoze(0f) }
@@ -586,7 +590,7 @@ constructor(
    internal fun listenForAnyStateToDozingTransition(scope: CoroutineScope): Job {
        return scope.launch {
            keyguardTransitionInteractor
                .transitionStepsToState(DOZING)
                .transition(Edge.create(to = DOZING))
                .filter { it.transitionState == TransitionState.FINISHED }
                .collect { handleDoze(1f) }
        }
+5 −5
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ import com.android.systemui.keyguard.KeyguardBottomAreaRefactor;
import com.android.systemui.keyguard.MigrateClocksToBlueprint;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.res.R;
@@ -167,9 +167,9 @@ public class LegacyLockIconViewController implements Dumpable, LockIconViewContr
    private LockIconView mView;

    @VisibleForTesting
    final Consumer<TransitionStep> mDozeTransitionCallback = (TransitionStep step) -> {
        mInterpolatedDarkAmount = step.getValue();
        mView.setDozeAmount(step.getValue());
    final Consumer<Float> mDozeTransitionCallback = (Float value) -> {
        mInterpolatedDarkAmount = value;
        mView.setDozeAmount(value);
        updateBurnInOffsets();
    };

@@ -265,7 +265,7 @@ public class LegacyLockIconViewController implements Dumpable, LockIconViewContr
        mView.setAccessibilityDelegate(mAccessibilityDelegate);

        if (mFeatureFlags.isEnabled(DOZING_MIGRATION_1)) {
            collectFlow(mView, mTransitionInteractor.getDozeAmountTransition(),
            collectFlow(mView, mTransitionInteractor.transitionValue(KeyguardState.AOD),
                    mDozeTransitionCallback);
            collectFlow(mView, mKeyguardInteractor.isDozing(), mIsDozingCallback);
        }
+6 −23
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED
import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
@@ -59,7 +58,6 @@ import java.io.PrintWriter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch

/** Class that coordinates non-HBM animations during keyguard authentication. */
@@ -307,30 +305,15 @@ open class UdfpsKeyguardViewControllerLegacy(
    @VisibleForTesting
    suspend fun listenForLockscreenAodTransitions(scope: CoroutineScope): Job {
        return scope.launch {
            transitionInteractor.dozeAmountTransition.collect { transitionStep ->
                if (
                    transitionStep.from == AOD &&
                        transitionStep.transitionState == TransitionState.CANCELED
                ) {
                    if (transitionInteractor.startedKeyguardTransitionStep.first().to != AOD) {
                        // If the next started transition isn't transitioning back to AOD, force
                        // doze amount to be 0f (as if the transition to the lockscreen completed).
                        view.onDozeAmountChanged(
                            0f,
                            0f,
                            UdfpsKeyguardViewLegacy.ANIMATION_NONE,
                        )
                    }
                } else {
            transitionInteractor.transitionValue(AOD).collect {
                view.onDozeAmountChanged(
                        transitionStep.value,
                        transitionStep.value,
                    it,
                    it,
                    UdfpsKeyguardViewLegacy.ANIMATION_BETWEEN_AOD_AND_LOCKSCREEN,
                )
            }
        }
    }
    }

    @VisibleForTesting
    suspend fun listenForBouncerExpansion(scope: CoroutineScope): Job {
Loading