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

Commit f8118c25 authored by Matt Pietal's avatar Matt Pietal
Browse files

[DO NOT MERGE] Transitions: PRIMARY_BOUNCER -> GONE

If the device unlocks while the bouncer is in transit, the bouncer
will remain visible over the launcher for half a second while the
appear animation completes while the scrim immediately
disappears (while also undergoing numerous bad requests to transition
to invalid states).

To fix, control this animation using the transition repo instead and
ignore all other incoming requests while it is running.

Also, support a new mode for canceling transitions. Some transitions
may want to continue from the canceled point, others may want to run
the starting transition in full.

Fixes: 268596047
Test: ScrimControllerTest KeyguardRepositoryImplTest
NotificationShadeWindowViewControllerTest
KeyguardTransitionScenariosTest KeyguardTransitionRepositoryTest
Test: manual - Tested all bouncer variations, with and without face
unlock

Change-Id: Ib3f7587574a4445dffdd75493851ed066e3f191d
parent c0b0e7fa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@
    <!-- The vertical margin between the date and the owner info. -->

    <!-- The translation for disappearing security views after having solved them. -->
    <dimen name="disappear_y_translation">-32dp</dimen>
    <dimen name="disappear_y_translation">-50dp</dimen>

    <!-- Dimens for animation for the Bouncer PIN view -->
    <dimen name="pin_view_trans_y_entry">120dp</dimen>
+3 −7
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import static java.lang.Integer.max;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
@@ -1068,13 +1067,10 @@ public class KeyguardSecurityContainer extends ConstraintLayout {

            int yTranslation = mResources.getDimensionPixelSize(R.dimen.disappear_y_translation);

            AnimatorSet anims = new AnimatorSet();
            ObjectAnimator yAnim = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, yTranslation);
            ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mView, View.ALPHA, 0f);

            anims.setInterpolator(Interpolators.STANDARD_ACCELERATE);
            anims.playTogether(alphaAnim, yAnim);
            anims.start();
            yAnim.setInterpolator(Interpolators.STANDARD_ACCELERATE);
            yAnim.setDuration(500);
            yAnim.start();
        }

        private void setupUserSwitcher() {
+6 −1
Original line number Diff line number Diff line
@@ -636,12 +636,17 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard

    public void startAppearAnimation() {
        if (mCurrentSecurityMode != SecurityMode.None) {
            mView.setAlpha(1f);
            setAlpha(1f);
            mView.startAppearAnimation(mCurrentSecurityMode);
            getCurrentSecurityController().startAppearAnimation();
        }
    }

    /** Set the alpha of the security container view */
    public void setAlpha(float alpha) {
        mView.setAlpha(alpha);
    }

    public boolean startDisappearAnimation(Runnable onFinishRunnable) {
        boolean didRunAnimation = false;

+28 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ interface KeyguardRepository {
     */
    val isKeyguardShowing: Flow<Boolean>

    /** Is the keyguard in a unlocked state? */
    val isKeyguardUnlocked: Flow<Boolean>

    /** Is an activity showing over the keyguard? */
    val isKeyguardOccluded: Flow<Boolean>

@@ -278,6 +281,31 @@ constructor(
            }
            .distinctUntilChanged()

    override val isKeyguardUnlocked: Flow<Boolean> =
        conflatedCallbackFlow {
                val callback =
                    object : KeyguardStateController.Callback {
                        override fun onUnlockedChanged() {
                            trySendWithFailureLogging(
                                keyguardStateController.isUnlocked,
                                TAG,
                                "updated isKeyguardUnlocked"
                            )
                        }
                    }

                keyguardStateController.addCallback(callback)
                // Adding the callback does not send an initial update.
                trySendWithFailureLogging(
                    keyguardStateController.isUnlocked,
                    TAG,
                    "initial isKeyguardUnlocked"
                )

                awaitClose { keyguardStateController.removeCallback(callback) }
            }
            .distinctUntilChanged()

    override val isKeyguardGoingAway: Flow<Boolean> = conflatedCallbackFlow {
        val callback =
            object : KeyguardStateController.Callback {
+18 −8
Original line number Diff line number Diff line
@@ -68,8 +68,11 @@ interface KeyguardTransitionRepository {
    /**
     * Begin a transition from one state to another. Transitions are interruptible, and will issue a
     * [TransitionStep] with state = [TransitionState.CANCELED] before beginning the next one.
     *
     * When canceled, there are two options: to continue from the current position of the prior
     * transition, or to reset the position. When [resetIfCanceled] == true, it will do the latter.
     */
    fun startTransition(info: TransitionInfo): UUID?
    fun startTransition(info: TransitionInfo, resetIfCanceled: Boolean = false): UUID?

    /**
     * Allows manual control of a transition. When calling [startTransition], the consumer must pass
@@ -130,7 +133,10 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio
        )
    }

    override fun startTransition(info: TransitionInfo): UUID? {
    override fun startTransition(
        info: TransitionInfo,
        resetIfCanceled: Boolean,
    ): UUID? {
        if (lastStep.from == info.from && lastStep.to == info.to) {
            Log.i(TAG, "Duplicate call to start the transition, rejecting: $info")
            return null
@@ -138,7 +144,11 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio
        val startingValue =
            if (lastStep.transitionState != TransitionState.FINISHED) {
                Log.i(TAG, "Transition still active: $lastStep, canceling")
                if (resetIfCanceled) {
                    0f
                } else {
                    lastStep.value
                }
            } else {
                0f
            }
@@ -227,10 +237,7 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio
    }

    private fun trace(step: TransitionStep, isManual: Boolean) {
        if (
            step.transitionState != TransitionState.STARTED &&
                step.transitionState != TransitionState.FINISHED
        ) {
        if (step.transitionState == TransitionState.RUNNING) {
            return
        }
        val traceName =
@@ -243,7 +250,10 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio
        val traceCookie = traceName.hashCode()
        if (step.transitionState == TransitionState.STARTED) {
            Trace.beginAsyncSection(traceName, traceCookie)
        } else if (step.transitionState == TransitionState.FINISHED) {
        } else if (
            step.transitionState == TransitionState.FINISHED ||
                step.transitionState == TransitionState.CANCELED
        ) {
            Trace.endAsyncSection(traceName, traceCookie)
        }
    }
Loading