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

Commit 8b11ea24 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

In ViewHierarchyAnimator, run onAnimationEnd even if anim was cancelled.

Bug: 344049884
Flag: EXEMPT bugfix
Test: Trigger chipbar, let it disappear, then swipe up to go to all apps
list -> verify you can interact with the search bar at the top of the
list
Test: atest ViewHierarchyAnimatorTest

Change-Id: I62f1ef56af797dc1b26c4f3d663c47ae307ee071
parent de5882f3
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -197,8 +197,8 @@ class ViewHierarchyAnimator {
         * @param includeFadeIn true if the animator should also fade in the view and child views.
         * @param fadeInInterpolator the interpolator to use when fading in the view. Unused if
         *   [includeFadeIn] is false.
         * @param onAnimationEnd an optional runnable that will be run once the animation
         *   finishes successfully. Will not be run if the animation is cancelled.
         * @param onAnimationEnd an optional runnable that will be run once the animation finishes,
         *   regardless of whether the animation is cancelled or finishes successfully.
         */
        @JvmOverloads
        fun animateAddition(
@@ -399,8 +399,8 @@ class ViewHierarchyAnimator {
         * added on the side(s) of the [destination], the translation of those margins can be
         * included by specifying [includeMargins].
         *
         * @param onAnimationEnd an optional runnable that will be run once the animation finishes
         *    successfully. Will not be run if the animation is cancelled.
         * @param onAnimationEnd an optional runnable that will be run once the animation finishes,
         *   regardless of whether the animation is cancelled or finishes successfully.
         */
        @JvmOverloads
        fun animateRemoval(
@@ -1070,10 +1070,11 @@ class ViewHierarchyAnimator {
                            // listener.
                            recursivelyRemoveListener(view)
                        }
                        if (!cancelled) {
                        // Run the end runnable regardless of whether the animation was cancelled or
                        // not - this ensures critical actions (like removing a window) always occur
                        // (see b/344049884).
                        onAnimationEnd?.run()
                    }
                    }

                    override fun onAnimationCancel(animation: Animator) {
                        cancelled = true
+4 −4
Original line number Diff line number Diff line
@@ -777,7 +777,7 @@ class ViewHierarchyAnimatorTest : SysuiTestCase() {
    }

    @Test
    fun animateAddition_runnableDoesNotRunWhenAnimationCancelled() {
    fun animateAddition_runnableRunsWhenAnimationCancelled() {
        var runnableRun = false
        val onAnimationEndRunnable = { runnableRun = true }

@@ -791,7 +791,7 @@ class ViewHierarchyAnimatorTest : SysuiTestCase() {

        cancelAnimation(rootView)

        assertEquals(false, runnableRun)
        assertEquals(true, runnableRun)
    }

    @Test
@@ -1370,7 +1370,7 @@ class ViewHierarchyAnimatorTest : SysuiTestCase() {
    }

    @Test
    fun animateRemoval_runnableDoesNotRunWhenAnimationCancelled() {
    fun animateRemoval_runnableRunsWhenAnimationCancelled() {
        var runnableRun = false
        val onAnimationEndRunnable = { runnableRun = true }

@@ -1381,7 +1381,7 @@ class ViewHierarchyAnimatorTest : SysuiTestCase() {
        ViewHierarchyAnimator.animateRemoval(removedView, onAnimationEnd = onAnimationEndRunnable)
        cancelAnimation(removedView)

        assertEquals(false, runnableRun)
        assertEquals(true, runnableRun)
    }

    @Test