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

Commit 93af1db6 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

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
parent fd1cc120
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -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 {