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

Commit 94cb9e5d authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Partially reverts ag/32760467 (reparent instead of relative layer).

We decided to revert to this approach because the problems with
reparenting are more feasible to fix than those with the relative
layer, which revolve around the new AppZoomOut.

rgl@ also thinks this is just a better approach in general and I
believe him.

Bug: 404508609
Fix: 407021260
Flag: com.android.systemui.move_transition_animation_layer
Test: atest ActivityTransitionAnimatorTest
Change-Id: I56bf1bdd447abcf7805da230d1fa21dee559031f
parent c912f0ab
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -109,14 +109,14 @@ constructor(
    private val disableWmTimeout: Boolean = false,

    /**
     * Whether we should disable the relative layer transaction that puts the opening/closing window
     * above the view's window. This should be set to true in tests only, where we can't currently
     * use a valid leash.
     * Whether we should disable the reparent transaction that puts the opening/closing window above
     * the view's window. This should be set to true in tests only, where we can't currently use a
     * valid leash.
     *
     * TODO(b/397180418): Remove this flag when we don't have the RemoteAnimation wrapper anymore
     *   and we can just inject a fake transaction.
     */
    private val skipRelativeLayerTransaction: Boolean = false,
    private val skipReparentTransaction: Boolean = false,
) {
    @JvmOverloads
    constructor(
@@ -1151,7 +1151,7 @@ constructor(
                    DelegatingAnimationCompletionListener(listener, this::dispose),
                    transitionAnimator,
                    disableWmTimeout,
                    skipRelativeLayerTransaction,
                    skipReparentTransaction,
                )
        }

@@ -1187,14 +1187,14 @@ constructor(
        disableWmTimeout: Boolean = false,

        /**
         * Whether we should disable the relative layer transaction that puts the opening/closing
         * window above the view's window. This should be set to true in tests only, where we can't
         * Whether we should disable the reparent transaction that puts the opening/closing window
         * above the view's window. This should be set to true in tests only, where we can't
         * currently use a valid leash.
         *
         * TODO(b/397180418): Remove this flag when we don't have the RemoteAnimation wrapper
         *   anymore and we can just inject a fake transaction.
         */
        private val skipRelativeLayerTransaction: Boolean = false,
        private val skipReparentTransaction: Boolean = false,
    ) : RemoteAnimationDelegate<IRemoteAnimationFinishedCallback> {
        private val transitionContainer = controller.transitionContainer
        private val context = transitionContainer.context
@@ -1217,11 +1217,11 @@ constructor(
        private var animation: TransitionAnimator.Animation? = null

        /**
         * Whether the opening/closing window needs to be moved in front of the view's window at the
         * Whether the opening/closing window needs to reparented to the view's window at the
         * beginning of the animation. Since we don't always do this, we need to keep track of it in
         * order to have the rest of the animation behave correctly.
         */
        var moveWindowToTheFront = false
        var reparent = false

        /**
         * A timeout to cancel the transition animation if the remote animation is not started or
@@ -1477,16 +1477,16 @@ constructor(
                transitionAnimator.isExpandingFullyAbove(controller.transitionContainer, endState)
            val windowState = startingWindowState ?: controller.windowAnimatorState

            // We only relayer launch animations. In current integrations, returns are not affected
            // by the issue solved by relayering, and they present additional problems when the
            // We only reparent launch animations. In current integrations, returns are not affected
            // by the issue solved by reparenting, and they present additional problems when the
            // view lives in the Status Bar.
            // TODO(b/397646693): remove this exception.
            val isEligibleForRelayering = controller.isLaunching
            val isEligibleForReparenting = controller.isLaunching
            val viewRoot = controller.transitionContainer.viewRootImpl
            val skipRelayering =
                skipRelativeLayerTransaction || !window.leash.isValid || viewRoot == null
            if (moveTransitionAnimationLayer() && isEligibleForRelayering && !skipRelayering) {
                moveWindowToTheFront = true
            val skipReparenting =
                skipReparentTransaction || !window.leash.isValid || viewRoot == null
            if (moveTransitionAnimationLayer() && isEligibleForReparenting && !skipReparenting) {
                reparent = true
            }

            // We animate the opening window and delegate the view expansion to [this.controller].
@@ -1556,13 +1556,13 @@ constructor(
                            )
                        }

                        if (moveWindowToTheFront) {
                        if (reparent) {
                            // Ensure that the launching window is rendered above the view's window,
                            // so it is not obstructed.
                            // TODO(b/397180418): re-use the start transaction once the
                            //  RemoteAnimation wrapper is cleaned up.
                            SurfaceControl.Transaction().use {
                                it.setRelativeLayer(window.leash, viewRoot.surfaceControl, 1)
                                it.reparent(window.leash, viewRoot.surfaceControl)
                                it.apply()
                            }
                        }
@@ -1620,7 +1620,7 @@ constructor(
                    null
                }
            val fadeWindowBackgroundLayer =
                if (moveWindowToTheFront) {
                if (reparent) {
                    false
                } else {
                    !controller.isBelowAnimatingWindow
@@ -1744,7 +1744,7 @@ constructor(
            // fade in progressively. Otherwise, it should be fully opaque and will be progressively
            // revealed as the window background color layer above the window fades out.
            val alpha =
                if (moveWindowToTheFront || controller.isBelowAnimatingWindow) {
                if (reparent || controller.isBelowAnimatingWindow) {
                    if (controller.isLaunching) {
                        interpolators.contentAfterFadeInInterpolator.getInterpolation(
                            windowProgress
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
                testTransitionAnimator,
                testTransitionAnimator,
                disableWmTimeout = true,
                skipRelativeLayerTransaction = true,
                skipReparentTransaction = true,
            )
        kosmos.activityTransitionAnimator.callback = callback
        kosmos.activityTransitionAnimator.addListener(listener)