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

Commit 49a5911f authored by Peter Kalauskas's avatar Peter Kalauskas Committed by Automerger Merge Worker
Browse files

Merge "Revert "Fix jank in CUJ_SCREEN_OFF_SHOW_AOD"" into udc-dev am: d8e67a7d

parents 03e88b6c d8e67a7d
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.phone.AnimatorHandle;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -48,7 +47,6 @@ public class KeyguardVisibilityHelper {
    private final ScreenOffAnimationController mScreenOffAnimationController;
    private boolean mAnimateYPos;
    private boolean mKeyguardViewVisibilityAnimating;
    private AnimatorHandle mKeyguardAnimatorHandle;
    private boolean mLastOccludedState = false;
    private final AnimationProperties mAnimationProperties = new AnimationProperties();
    private final LogBuffer mLogBuffer;
@@ -85,10 +83,6 @@ public class KeyguardVisibilityHelper {
            boolean keyguardFadingAway,
            boolean goingToFullShade,
            int oldStatusBarState) {
        if (mKeyguardAnimatorHandle != null) {
            mKeyguardAnimatorHandle.cancel();
            mKeyguardAnimatorHandle = null;
        }
        mView.animate().cancel();
        boolean isOccluded = mKeyguardStateController.isOccluded();
        mKeyguardViewVisibilityAnimating = false;
@@ -122,7 +116,7 @@ public class KeyguardVisibilityHelper {
                    .setDuration(320)
                    .setInterpolator(Interpolators.ALPHA_IN)
                    .withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable);
            log("keyguardFadingAway transition w/ Y Animation");
            log("keyguardFadingAway transition w/ Y Aniamtion");
        } else if (statusBarState == KEYGUARD) {
            if (keyguardFadingAway) {
                mKeyguardViewVisibilityAnimating = true;
@@ -154,7 +148,7 @@ public class KeyguardVisibilityHelper {

                // Ask the screen off animation controller to animate the keyguard visibility for us
                // since it may need to be cancelled due to keyguard lifecycle events.
                mKeyguardAnimatorHandle = mScreenOffAnimationController.animateInKeyguard(
                mScreenOffAnimationController.animateInKeyguard(
                        mView, mAnimateKeyguardStatusViewVisibleEndRunnable);
            } else {
                log("Direct set Visibility to VISIBLE");
+7 −15
Original line number Diff line number Diff line
@@ -85,16 +85,15 @@ class ScreenOffAnimationController @Inject constructor(

    /**
     * Called when keyguard is about to be displayed and allows to perform custom animation
     *
     * @return A handle that can be used for cancelling the animation, if necessary
     */
    fun animateInKeyguard(keyguardView: View, after: Runnable): AnimatorHandle? {
        animations.forEach {
    fun animateInKeyguard(keyguardView: View, after: Runnable) =
        animations.firstOrNull {
            if (it.shouldAnimateInKeyguard()) {
                return@animateInKeyguard it.animateInKeyguard(keyguardView, after)
            }
                it.animateInKeyguard(keyguardView, after)
                true
            } else {
                false
            }
        return null
        }

    /**
@@ -212,10 +211,7 @@ interface ScreenOffAnimation {
    fun onAlwaysOnChanged(alwaysOn: Boolean) {}

    fun shouldAnimateInKeyguard(): Boolean = false
    fun animateInKeyguard(keyguardView: View, after: Runnable): AnimatorHandle? {
        after.run()
        return null
    }
    fun animateInKeyguard(keyguardView: View, after: Runnable) = after.run()

    fun shouldDelayKeyguardShow(): Boolean = false
    fun isKeyguardShowDelayed(): Boolean = false
@@ -228,7 +224,3 @@ interface ScreenOffAnimation {
    fun shouldAnimateDozingChange(): Boolean = true
    fun shouldAnimateClockChange(): Boolean = true
}

interface AnimatorHandle {
    fun cancel()
}
 No newline at end of file
+14 −32
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
     * Animates in the provided keyguard view, ending in the same position that it will be in on
     * AOD.
     */
    override fun animateInKeyguard(keyguardView: View, after: Runnable): AnimatorHandle {
    override fun animateInKeyguard(keyguardView: View, after: Runnable) {
        shouldAnimateInKeyguard = false
        keyguardView.alpha = 0f
        keyguardView.visibility = View.VISIBLE
@@ -175,36 +175,11 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        // We animate the Y properly separately using the PropertyAnimator, as the panel
        // view also needs to update the end position.
        PropertyAnimator.cancelAnimation(keyguardView, AnimatableProperty.Y)

        // Start the animation on the next frame using Choreographer APIs. animateInKeyguard() is
        // called while the system is busy processing lots of requests, so delaying the animation a
        // frame will mitigate jank. In the event the animation is cancelled before the next frame
        // is called, this callback will be removed
        val keyguardAnimator = keyguardView.animate()
        val nextFrameCallback = TraceUtils.namedRunnable("startAnimateInKeyguard") {
            PropertyAnimator.setProperty(keyguardView, AnimatableProperty.Y, currentY,
        PropertyAnimator.setProperty<View>(keyguardView, AnimatableProperty.Y, currentY,
                AnimationProperties().setDuration(duration.toLong()),
                true /* animate */)
            keyguardAnimator.start()
        }
        DejankUtils.postAfterTraversal(nextFrameCallback)
        val animatorHandle = object : AnimatorHandle {
            private var hasCancelled = false
            override fun cancel() {
                if (!hasCancelled) {
                    DejankUtils.removeCallbacks(nextFrameCallback)
                    // If we're cancelled, reset state flags/listeners. The end action above
                    // will not be called, which is what we want since that will finish the
                    // screen off animation and show the lockscreen, which we don't want if we
                    // were cancelled.
                    aodUiAnimationPlaying = false
                    decidedToAnimateGoingToSleep = null
                    keyguardView.animate().setListener(null)
                    hasCancelled = true
                }
            }
        }
        keyguardAnimator

        keyguardView.animate()
                .setDuration(duration.toLong())
                .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
                .alpha(1f)
@@ -230,7 +205,14 @@ class UnlockedScreenOffAnimationController @Inject constructor(
                }
                .setListener(object : AnimatorListenerAdapter() {
                    override fun onAnimationCancel(animation: Animator?) {
                        animatorHandle.cancel()
                        // If we're cancelled, reset state flags/listeners. The end action above
                        // will not be called, which is what we want since that will finish the
                        // screen off animation and show the lockscreen, which we don't want if we
                        // were cancelled.
                        aodUiAnimationPlaying = false
                        decidedToAnimateGoingToSleep = null
                        keyguardView.animate().setListener(null)

                        interactionJankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD)
                    }

@@ -240,7 +222,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
                                CUJ_SCREEN_OFF_SHOW_AOD)
                    }
                })
        return animatorHandle
                .start()
    }

    override fun onStartedWakingUp() {