From 93af1db6a3a825a4f52d6d3e5faabe53840f54d6 Mon Sep 17 00:00:00 2001 From: Johannes Gallmann Date: Tue, 16 Jul 2024 12:05:38 +0200 Subject: [PATCH] Fix CUJ_LAUNCHER_APP_CLOSE_TO_HOME Cuj for predictive back to home CUJ_LAUNCHER_APP_CLOSE_TO_HOME was broken because in the non-fallback case, the anim on which addCujInstrumentation was called on was empty. Bug: 300078127 Flag: com.android.window.flags.predictive_back_system_anims Test: Manual, i.e. verifying that CUJ_LAUNCHER_APP_CLOSE_TO_HOME shows up properly in perfetto trace with the fix applied in the predictive back case Change-Id: I4a1130bd7c4622c057db054d829f662a16443799 --- .../launcher3/QuickstepTransitionManager.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) 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 {