Add ACTION_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE latency (launcher).

This measures the delay from when the user closes or minimizes
the last open window in desktop mode until the animation to exit
desktop mode draws its first frame.

Flag: EXEMPT metric change

Bug: 390544490
Test: Run `statsd_testdrive 306` and ensure that latency metric is
      reported.
Change-Id: If4923b50feade20ba74560ed7b8d14ea2bb6f71e
This commit is contained in:
Eric Sum committed 2025-03-26 10:41:39 -07:00
1 parent 66ac9dc459
commit 66e5325d6f
2 files changed
+40 -9

No files matched your search

@@ -40,6 +40,7 @@ import static com.android.app.animation.Interpolators.DECELERATE_1_5;
import static com.android.app.animation.Interpolators.DECELERATE_1_7;
import static com.android.app.animation.Interpolators.EXAGGERATED_EASE;
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.internal.util.LatencyTracker.ACTION_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE;
import static com.android.launcher3.BaseActivity.EVENT_DESTROYED;
import static com.android.launcher3.BaseActivity.INVISIBLE_ALL;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS;
@@ -122,6 +123,7 @@ import androidx.core.graphics.ColorUtils;
import com.android.app.animation.Animations;
import com.android.internal.jank.Cuj;
import com.android.internal.util.LatencyTracker;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory;
import com.android.launcher3.anim.AnimationSuccessListener;
@@ -263,6 +265,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
private RemoteTransition mLauncherOpenTransition;
private final RemoteAnimationCoordinateTransfer mCoordinateTransfer;
private final LatencyTracker mLatencyTracker;
private LauncherBackAnimationController mBackAnimationController;
private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() {
@@ -317,6 +320,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
mOpeningInterpolator = AnimationUtils.loadInterpolator(context,
R.interpolator.emphasized_interpolator);
mCoordinateTransfer = new RemoteAnimationCoordinateTransfer(mLauncher);
mLatencyTracker = LatencyTracker.getInstance(context);
}
@Override
@@ -1630,14 +1634,20 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
}
private void addCujInstrumentation(Animator anim, int cuj) {
anim.addListener(getCujAnimationSuccessListener(cuj));
anim.addListener(getCujAnimationSuccessListener(cuj, /* cujPreStartCallback= */null));
}
private void addCujInstrumentation(Animator anim, int cuj, Runnable cujPreStartCallback) {
anim.addListener(getCujAnimationSuccessListener(cuj, cujPreStartCallback));
}
private void addCujInstrumentation(RectFSpringAnim anim, int cuj) {
anim.addAnimatorListener(getCujAnimationSuccessListener(cuj));
anim.addAnimatorListener(
getCujAnimationSuccessListener(cuj, /* cujPreStartCallback= */null));
}
private AnimationSuccessListener getCujAnimationSuccessListener(int cuj) {
private AnimationSuccessListener getCujAnimationSuccessListener(
int cuj, Runnable cujPreStartCallback) {
return new AnimationSuccessListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -1651,7 +1661,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
return;
}
mHandled = true;
if (cujPreStartCallback != null) {
cujPreStartCallback.run();
}
InteractionJankMonitorWrapper.begin(mDragLayer, cuj);
mDragLayer.post(() ->
@@ -1803,8 +1815,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
addCujInstrumentation(rectFSpringAnim, Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME);
} else {
if (isFreeformAnimation(appTargets)) {
addCujInstrumentation(anim,
Cuj.CUJ_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE);
addCujInstrumentation(
anim,
Cuj.CUJ_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE,
/* cujPreStartCallback= */ () -> {
mLatencyTracker.onActionEnd(
ACTION_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE);
});
}
addCujInstrumentation(anim, playFallBackAnimation
? Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME_FALLBACK