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

Commit 65a914c0 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Automerger Merge Worker
Browse files

Merge "Post ActivityLaunchAnimator timeout on Looper.mainLooper()" into udc-qpr-dev am: e39151d5

parents 095123c0 e39151d5
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.Path
import android.graphics.Rect
import android.graphics.RectF
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.os.RemoteException
import android.util.Log
@@ -58,7 +59,14 @@ class ActivityLaunchAnimator(
    /** The animator used when animating a Dialog into an app. */
    // TODO(b/218989950): Remove this animator and instead set the duration of the dim fade out to
    // TIMINGS.contentBeforeFadeOutDuration.
    private val dialogToAppAnimator: LaunchAnimator = DEFAULT_DIALOG_TO_APP_ANIMATOR
    private val dialogToAppAnimator: LaunchAnimator = DEFAULT_DIALOG_TO_APP_ANIMATOR,

    /**
     * Whether we should disable the WindowManager timeout. This should be set to true in tests
     * only.
     */
    // TODO(b/301385865): Remove this flag.
    private val disableWmTimeout: Boolean = false,
) {
    companion object {
        /** The timings when animating a View into an app. */
@@ -431,7 +439,8 @@ class ActivityLaunchAnimator(
        internal val delegate: AnimationDelegate

        init {
            delegate = AnimationDelegate(controller, callback, listener, launchAnimator)
            delegate =
                AnimationDelegate(controller, callback, listener, launchAnimator, disableWmTimeout)
        }

        @BinderThread
@@ -461,13 +470,26 @@ class ActivityLaunchAnimator(
        /** Listener for animation lifecycle events. */
        private val listener: Listener? = null,
        /** The animator to use to animate the window launch. */
        private val launchAnimator: LaunchAnimator = DEFAULT_LAUNCH_ANIMATOR
        private val launchAnimator: LaunchAnimator = DEFAULT_LAUNCH_ANIMATOR,

        /**
         * Whether we should disable the WindowManager timeout. This should be set to true in tests
         * only.
         */
        // TODO(b/301385865): Remove this flag.
        disableWmTimeout: Boolean = false,
    ) : RemoteAnimationDelegate<IRemoteAnimationFinishedCallback> {
        private val launchContainer = controller.launchContainer
        private val context = launchContainer.context
        private val transactionApplierView =
            controller.openingWindowSyncView ?: controller.launchContainer
        private val transactionApplier = SyncRtSurfaceTransactionApplier(transactionApplierView)
        private val timeoutHandler =
            if (!disableWmTimeout) {
                Handler(Looper.getMainLooper())
            } else {
                null
            }

        private val matrix = Matrix()
        private val invertMatrix = Matrix()
@@ -487,11 +509,11 @@ class ActivityLaunchAnimator(

        @UiThread
        internal fun postTimeout() {
            launchContainer.postDelayed(onTimeout, LAUNCH_TIMEOUT)
            timeoutHandler?.postDelayed(onTimeout, LAUNCH_TIMEOUT)
        }

        private fun removeTimeout() {
            launchContainer.removeCallbacks(onTimeout)
            timeoutHandler?.removeCallbacks(onTimeout)
        }

        @UiThread
+2 −1
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {

    @Before
    fun setup() {
        activityLaunchAnimator = ActivityLaunchAnimator(testLaunchAnimator, testLaunchAnimator)
        activityLaunchAnimator =
            ActivityLaunchAnimator(testLaunchAnimator, testLaunchAnimator, disableWmTimeout = true)
        activityLaunchAnimator.callback = callback
        activityLaunchAnimator.addListener(listener)
    }