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

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

Merge "Reinstate the original fix for Flexi flicker, gated behind Flexi." into main

parents 5175a303 eaeae164
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALW
import com.android.app.animation.Interpolators
import com.android.internal.jank.Cuj.CujType
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.Flags
import com.android.systemui.util.maybeForceFullscreen
import com.android.systemui.util.registerAnimationOnBackInvoked
import java.util.concurrent.Executor
@@ -932,26 +933,29 @@ private class AnimatedDialog(
                }

                override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) {
                    // onLaunchAnimationEnd is called by an Animator at the end of the animation,
                    // on a Choreographer animation tick. The following calls will move the animated
                    // content from the dialog overlay back to its original position, and this
                    // change must be reflected in the next frame given that we then sync the next
                    // frame of both the content and dialog ViewRoots. However, in case that content
                    // is rendered by Compose, whose compositions are also scheduled on a
                    // Choreographer frame, any state change made *right now* won't be reflected in
                    // the next frame given that a Choreographer frame can't schedule another and
                    // have it happen in the same frame. So we post the forwarded calls to
                    // [Controller.onLaunchAnimationEnd], leaving this Choreographer frame, ensuring
                    // that the move of the content back to its original window will be reflected in
                    // the next frame right after [onLaunchAnimationEnd] is called.
                    //
                    // TODO(b/330672236): Move this to TransitionAnimator.
                    dialog.context.mainExecutor.execute {
                    val onEnd = {
                        startController.onTransitionAnimationEnd(isExpandingFullyAbove)
                        endController.onTransitionAnimationEnd(isExpandingFullyAbove)

                        onLaunchAnimationEnd()
                    }
                    if (Flags.sceneContainer()) {
                        onEnd()
                    } else {
                        // onLaunchAnimationEnd is called by an Animator at the end of the
                        // animation, on a Choreographer animation tick. The following calls will
                        // move the animated content from the dialog overlay back to its original
                        // position, and this change must be reflected in the next frame given that
                        // we then sync the next frame of both the content and dialog ViewRoots.
                        // However, in case that content is rendered by Compose, whose compositions
                        // are also scheduled on a Choreographer frame, any state change made *right
                        // now* won't be reflected in the next frame given that a Choreographer
                        // frame can't schedule another and have it happen in the same frame. So we
                        // post the forwarded calls to [Controller.onLaunchAnimationEnd], leaving
                        // this Choreographer frame, ensuring that the move of the content back to
                        // its original window will be reflected in the next frame right after
                        // [onLaunchAnimationEnd] is called.
                        dialog.context.mainExecutor.execute { onEnd() }
                    }
                }

                override fun onTransitionAnimationProgress(
+4 −5
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.app.animation.Interpolators.LINEAR
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.dynamicanimation.animation.SpringAnimation
import com.android.internal.dynamicanimation.animation.SpringForce
import com.android.systemui.Flags
import com.android.systemui.Flags.moveTransitionAnimationLayer
import com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary
import com.android.systemui.shared.Flags.returnAnimationFrameworkLongLived
@@ -1014,11 +1015,7 @@ class TransitionAnimator(
                openingWindowSyncViewOverlay?.remove(windowBackgroundLayer)
            }
        }
        // TODO(b/330672236): Post this to the main thread for launches as well, so that they do not
        //   flicker with Flexiglass enabled.
        if (controller.isLaunching) {
            onEnd()
        } else {
        if (Flags.sceneContainer() || !controller.isLaunching) {
            // onAnimationEnd is called at the end of the animation, on a Choreographer animation
            // tick. During dialog launches, the following calls will move the animated content from
            // the dialog overlay back to its original position, and this change must be reflected
@@ -1032,6 +1029,8 @@ class TransitionAnimator(
            // Choreographer frame, ensuring that any state change applied by
            // onTransitionAnimationEnd() will be reflected in the same frame.
            mainExecutor.execute { onEnd() }
        } else {
            onEnd()
        }
    }