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

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

Merge changes I267e4e3c,Ia69806fa into main

* changes:
  Clean up aconfig flag activity_transition_use_largest_window.
  Clean up unused navbar code from ActivityTransitionAnimator.
parents a62ead58 61b1dcf5
Loading
Loading
Loading
Loading
+24 −101
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ import androidx.annotation.UiThread
import com.android.app.animation.Interpolators
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.policy.ScreenDecorationsUtils
import com.android.systemui.Flags.activityTransitionUseLargestWindow
import com.android.systemui.Flags.animationLibraryDelayLeashCleanup
import com.android.systemui.Flags.moveTransitionAnimationLayer
import com.android.systemui.Flags.translucentOccludingActivityFix
@@ -1279,12 +1278,7 @@ constructor(
            val window = setUpAnimation(apps, callback) ?: return

            if (controller.windowAnimatorState == null || !longLivedReturnAnimationsEnabled()) {
                val navigationBar =
                    nonApps?.firstOrNull {
                        it.windowType == WindowManager.LayoutParams.TYPE_NAVIGATION_BAR
                    }

                startAnimation(window, navigationBar, iCallback = callback)
                startAnimation(window, iCallback = callback)
            } else {
                // If a [controller.windowAnimatorState] exists, treat this like a takeover.
                takeOverAnimationInternal(
@@ -1316,14 +1310,7 @@ constructor(
        ) {
            val useSpring =
                !controller.isLaunching && startWindowState != null && startTransaction != null
            startAnimation(
                window,
                navigationBar = null,
                useSpring,
                startWindowState,
                startTransaction,
                callback,
            )
            startAnimation(window, useSpring, startWindowState, startTransaction, callback)
        }

        @UiThread
@@ -1382,16 +1369,14 @@ constructor(

            for (it in apps) {
                if (it.mode == targetMode) {
                    if (activityTransitionUseLargestWindow()) {
                    if (returnAnimationsEnabled()) {
                        // If the controller contains a cookie, _only_ match if either the
                        // candidate contains the matching cookie, or a component is also
                        // defined and is a match.
                        if (
                            controller.transitionCookie != null &&
                                    it.taskInfo
                                        ?.launchCookies
                                        ?.contains(controller.transitionCookie) != true &&
                                it.taskInfo?.launchCookies?.contains(controller.transitionCookie) !=
                                    true &&
                                (controller.component == null ||
                                    it.taskInfo?.topActivity != controller.component)
                        ) {
@@ -1400,8 +1385,7 @@ constructor(
                    }

                    if (
                            candidate == null ||
                                !it.hasAnimatingParent && candidate.hasAnimatingParent
                        candidate == null || !it.hasAnimatingParent && candidate.hasAnimatingParent
                    ) {
                        candidate = it
                        continue
@@ -1412,14 +1396,6 @@ constructor(
                    ) {
                        candidate = it
                    }
                    } else {
                        if (!it.hasAnimatingParent) {
                            return it
                        }
                        if (candidate == null) {
                            candidate = it
                        }
                    }
                }
            }

@@ -1428,7 +1404,6 @@ constructor(

        private fun startAnimation(
            window: RemoteAnimationTarget,
            navigationBar: RemoteAnimationTarget? = null,
            useSpring: Boolean = false,
            startingWindowState: WindowAnimationState? = null,
            startTransaction: SurfaceControl.Transaction? = null,
@@ -1650,7 +1625,6 @@ constructor(
                        linearProgress: Float,
                    ) {
                        applyStateToWindow(window, state, linearProgress, useSpring)
                        navigationBar?.let { applyStateToNavigationBar(it, state, linearProgress) }

                        listener?.onTransitionAnimationProgress(linearProgress)
                        delegate.onTransitionAnimationProgress(state, progress, linearProgress)
@@ -1826,57 +1800,6 @@ constructor(
            transactionApplier.scheduleApply(params.build())
        }

        // TODO(b/377643129): remote transitions have no way of identifying the navbar when
        //  converting to RemoteAnimationTargets (and in my testing it was never included in the
        //  transition at all). So this method is not used anymore. Remove or adapt once we fully
        //  convert to remote transitions.
        private fun applyStateToNavigationBar(
            navigationBar: RemoteAnimationTarget,
            state: TransitionAnimator.State,
            linearProgress: Float,
        ) {
            if (transactionApplierView.viewRootImpl == null || !navigationBar.leash.isValid) {
                // Don't apply any transaction if the view root we synchronize with was detached or
                // if the SurfaceControl associated with [navigationBar] is not valid, as
                // [SyncRtSurfaceTransactionApplier.scheduleApply] would otherwise throw.
                return
            }

            val fadeInProgress =
                TransitionAnimator.getProgress(
                    TIMINGS,
                    linearProgress,
                    ANIMATION_DELAY_NAV_FADE_IN,
                    ANIMATION_DURATION_NAV_FADE_OUT,
                )

            val params = SyncRtSurfaceTransactionApplier.SurfaceParams.Builder(navigationBar.leash)
            if (fadeInProgress > 0) {
                matrix.reset()
                matrix.setTranslate(
                    0f,
                    (state.top - navigationBar.sourceContainerBounds.top).toFloat(),
                )
                windowCrop.set(state.left, 0, state.right, state.height)
                params
                    .withAlpha(NAV_FADE_IN_INTERPOLATOR.getInterpolation(fadeInProgress))
                    .withMatrix(matrix)
                    .withWindowCrop(windowCrop)
                    .withVisibility(true)
            } else {
                val fadeOutProgress =
                    TransitionAnimator.getProgress(
                        TIMINGS,
                        linearProgress,
                        0,
                        ANIMATION_DURATION_NAV_FADE_OUT,
                    )
                params.withAlpha(1f - NAV_FADE_OUT_INTERPOLATOR.getInterpolation(fadeOutProgress))
            }

            transactionApplier.scheduleApply(params.build())
        }

        private fun onAnimationTimedOut() {
            // The remote animation was cancelled by WM, so we already cancelled the transition
            // animation.