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

Commit 7fdb63a2 authored by Luca Zuccarini's avatar Luca Zuccarini Committed by Android (Google) Code Review
Browse files

Merge "Don't disable the Shade's blur during launches." into main

parents a17dc87c 68ccd498
Loading
Loading
Loading
Loading
+55 −2
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ import java.util.Optional
import javax.inject.Inject
import kotlin.math.max
import kotlin.math.sign
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

/**
 * Responsible for blurring the notification shade window, and applying a zoom effect to the
@@ -92,6 +94,7 @@ constructor(
        private const val MIN_VELOCITY = -MAX_VELOCITY
        private const val INTERACTION_BLUR_FRACTION = 0.8f
        private const val ANIMATION_BLUR_FRACTION = 1f - INTERACTION_BLUR_FRACTION
        private const val TRANSITION_THRESHOLD = 0.98f
        private const val TAG = "DepthController"
    }

@@ -156,6 +159,9 @@ constructor(
    /**
     * When launching an app from the shade, the animations progress should affect how blurry the
     * shade is, overriding the expansion amount.
     *
     * TODO(b/399617511): remove this once [Flags.notificationShadeBlur] is launched and the Shade
     *   closing is actually instantaneous.
     */
    var blursDisabledForAppLaunch: Boolean = false
        set(value) {
@@ -185,9 +191,13 @@ constructor(
                return
            }

            if (Flags.notificationShadeBlur()) {
                shadeAnimation.skipTo(0)
            } else {
                shadeAnimation.animateTo(0)
                shadeAnimation.finishIfRunning()
            }
        }
        @Deprecated(
            message =
                "This might get reset to false before shade expansion is fully done, " +
@@ -487,6 +497,22 @@ constructor(
        scheduleUpdate()
    }

    fun onTransitionAnimationProgress(progress: Float) {
        if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) return
        // Because the Shade takes a few frames to actually trigger the unblur after a transition
        // has ended, we need to disable it manually, or the opening window itself will be blurred
        // for a few frames due to relative ordering. We do this towards the end, so that the
        // window is already covering the background and the unblur is not visible.
        if (progress >= TRANSITION_THRESHOLD && shadeAnimation.radius > 0) {
            blursDisabledForAppLaunch = true
        }
    }

    fun onTransitionAnimationEnd() {
        if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) return
        blursDisabledForAppLaunch = false
    }

    private fun updateShadeAnimationBlur(
        expansion: Float,
        tracking: Boolean,
@@ -631,6 +657,20 @@ constructor(
            springAnimation.addEndListener { _, _, _, _ -> pendingRadius = -1 }
        }

        /**
         * Starts an animation to [newRadius], or updates the current one if already ongoing.
         * IMPORTANT: do NOT use this method + [finishIfRunning] to instantaneously change the value
         * of the animation. The change will NOT be instantaneous. Use [skipTo] instead.
         *
         * Explanation:
         * 1. If idle, [SpringAnimation.animateToFinalPosition] requests a start to the animation.
         * 2. On the first frame after an idle animation is requested to start, the animation simply
         *    acquires the starting value and does nothing else.
         * 3. [SpringAnimation.skipToEnd] requests a fast-forward to the end value, but this happens
         *    during calculation of the next animation value. Because on the first frame no such
         *    calculation happens (point #2), there is one lagging frame where we still see the old
         *    value.
         */
        fun animateTo(newRadius: Int) {
            if (pendingRadius == newRadius) {
                return
@@ -639,6 +679,19 @@ constructor(
            springAnimation.animateToFinalPosition(newRadius.toFloat())
        }

        /**
         * Instantaneously set a new blur radius to this animation. Always use this instead of
         * [animateTo] and [finishIfRunning] to make sure that the change takes effect in the next
         * frame. See the doc for [animateTo] for an explanation.
         */
        fun skipTo(newRadius: Int) {
            if (pendingRadius == newRadius) return
            pendingRadius = newRadius
            springAnimation.cancel()
            springAnimation.setStartValue(newRadius.toFloat())
            springAnimation.animateToFinalPosition(newRadius.toFloat())
        }

        fun finishIfRunning() {
            if (springAnimation.isRunning) {
                springAnimation.skipToEnd()
+18 −2
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ import com.android.systemui.AutoReinflateContainer;
import com.android.systemui.CoreStartable;
import com.android.systemui.DejankUtils;
import com.android.systemui.EventLogTags;
import com.android.systemui.Flags;
import com.android.systemui.InitController;
import com.android.systemui.Prefs;
import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController;
@@ -3183,13 +3184,28 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
            new ActivityTransitionAnimator.Listener() {
                @Override
                public void onTransitionAnimationStart() {
                    if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) {
                        mKeyguardViewMediator.setBlursDisabledForAppLaunch(true);
                    }
                }

                @Override
                public void onTransitionAnimationProgress(float linearProgress) {
                    if (Flags.notificationShadeBlur() && Flags.moveTransitionAnimationLayer()) {
                        mNotificationShadeDepthControllerLazy.get()
                                .onTransitionAnimationProgress(linearProgress);
                    }
                }

                @Override
                public void onTransitionAnimationEnd() {
                    if (Flags.notificationShadeBlur() && Flags.moveTransitionAnimationLayer()) {
                        mNotificationShadeDepthControllerLazy.get()
                                .onTransitionAnimationEnd();
                    } else {
                        mKeyguardViewMediator.setBlursDisabledForAppLaunch(false);
                    }
                }
            };

    private final DemoMode mDemoModeCallback = new DemoMode() {