diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 5a74f4aafc..5e5487bb8e 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1644,7 +1644,15 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener } private void addCujInstrumentation(Animator anim, int cuj) { - anim.addListener(new AnimationSuccessListener() { + anim.addListener(getCujAnimationSuccessListener(cuj)); + } + + private void addCujInstrumentation(RectFSpringAnim anim, int cuj) { + anim.addAnimatorListener(getCujAnimationSuccessListener(cuj)); + } + + private AnimationSuccessListener getCujAnimationSuccessListener(int cuj) { + return new AnimationSuccessListener() { @Override public void onAnimationStart(Animator animation) { mDragLayer.getViewTreeObserver().addOnDrawListener( @@ -1678,7 +1686,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener public void onAnimationSuccess(Animator animator) { InteractionJankMonitorWrapper.end(cuj); } - }); + }; } /** @@ -1759,10 +1767,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener // invisibility on touch down, and only reset it after the animation to home // is initialized. if (launcherIsForceInvisibleOrOpening || fromPredictiveBack) { - addCujInstrumentation(anim, playFallBackAnimation - ? Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME_FALLBACK - : Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME); - AnimatorListenerAdapter endListener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -1772,6 +1776,14 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener } }; + if (rectFSpringAnim != null && anim.getChildAnimations().isEmpty()) { + addCujInstrumentation(rectFSpringAnim, Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME); + } else { + addCujInstrumentation(anim, playFallBackAnimation + ? Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME_FALLBACK + : Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME); + } + if (fromPredictiveBack && rectFSpringAnim != null) { rectFSpringAnim.addAnimatorListener(endListener); } else {