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

Commit eaeae164 authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Reinstate the original fix for Flexi flicker, gated behind Flexi.

Fix: 330672236
Flag: com.android.systemui.scene_container
Test: atest DialogTransitionAnimatorTest TransitionAnimatorTest + manual verification
Change-Id: I67018403ec90434905c706b4f633da4d6c0cea2e
parent f6d3e7a7
Loading
Loading
Loading
Loading
+20 −16
Original line number Original line 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.app.animation.Interpolators
import com.android.internal.jank.Cuj.CujType
import com.android.internal.jank.Cuj.CujType
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.Flags
import com.android.systemui.util.maybeForceFullscreen
import com.android.systemui.util.maybeForceFullscreen
import com.android.systemui.util.registerAnimationOnBackInvoked
import com.android.systemui.util.registerAnimationOnBackInvoked
import java.util.concurrent.Executor
import java.util.concurrent.Executor
@@ -932,26 +933,29 @@ private class AnimatedDialog(
                }
                }


                override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) {
                override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) {
                    // onLaunchAnimationEnd is called by an Animator at the end of the animation,
                    val onEnd = {
                    // 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 {
                        startController.onTransitionAnimationEnd(isExpandingFullyAbove)
                        startController.onTransitionAnimationEnd(isExpandingFullyAbove)
                        endController.onTransitionAnimationEnd(isExpandingFullyAbove)
                        endController.onTransitionAnimationEnd(isExpandingFullyAbove)

                        onLaunchAnimationEnd()
                        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(
                override fun onTransitionAnimationProgress(
+4 −5
Original line number Original line 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.annotations.VisibleForTesting
import com.android.internal.dynamicanimation.animation.SpringAnimation
import com.android.internal.dynamicanimation.animation.SpringAnimation
import com.android.internal.dynamicanimation.animation.SpringForce
import com.android.internal.dynamicanimation.animation.SpringForce
import com.android.systemui.Flags
import com.android.systemui.Flags.moveTransitionAnimationLayer
import com.android.systemui.Flags.moveTransitionAnimationLayer
import com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary
import com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary
import com.android.systemui.shared.Flags.returnAnimationFrameworkLongLived
import com.android.systemui.shared.Flags.returnAnimationFrameworkLongLived
@@ -1014,11 +1015,7 @@ class TransitionAnimator(
                openingWindowSyncViewOverlay?.remove(windowBackgroundLayer)
                openingWindowSyncViewOverlay?.remove(windowBackgroundLayer)
            }
            }
        }
        }
        // TODO(b/330672236): Post this to the main thread for launches as well, so that they do not
        if (Flags.sceneContainer() || !controller.isLaunching) {
        //   flicker with Flexiglass enabled.
        if (controller.isLaunching) {
            onEnd()
        } else {
            // onAnimationEnd is called at the end of the animation, on a Choreographer animation
            // 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
            // 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
            // 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
            // Choreographer frame, ensuring that any state change applied by
            // onTransitionAnimationEnd() will be reflected in the same frame.
            // onTransitionAnimationEnd() will be reflected in the same frame.
            mainExecutor.execute { onEnd() }
            mainExecutor.execute { onEnd() }
        } else {
            onEnd()
        }
        }
    }
    }