From 12d8222124ea9f24e8dd7daa7336ae04b4074ce3 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 7 Jan 2021 14:50:52 -0800 Subject: [PATCH] Starting CUJ_APP_CLOSE_TO_HOME metric earlier Now starting it at the very start of the gesture. Test: Manual Bug: 174892351 Change-Id: I9c36b4e4ae51302fc1c6b99b825358fb647cd310 --- .../android/quickstep/AbsSwipeUpHandler.java | 21 ++++++++----------- .../quickstep/RecentsAnimationController.java | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index f82bc2d698..5f196feaa1 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -723,6 +723,8 @@ public abstract class AbsSwipeUpHandler, Q extends public void onGestureStarted(boolean isLikelyToStartNewTask) { InteractionJankMonitorWrapper.begin( InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); + InteractionJankMonitorWrapper.begin( + InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); notifyGestureStartedAsync(); setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */); mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED); @@ -802,6 +804,13 @@ public abstract class AbsSwipeUpHandler, Q extends // Fast-finish the attaching animation if it's still running. maybeUpdateRecentsAttachedState(false); final GestureEndTarget endTarget = mGestureState.getEndTarget(); + if (endTarget != NEW_TASK) { + InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + } + if (endTarget != HOME) { + InteractionJankMonitorWrapper.cancel( + InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); + } switch (endTarget) { case HOME: mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT); @@ -820,9 +829,6 @@ public abstract class AbsSwipeUpHandler, Q extends break; } ActiveGestureLog.INSTANCE.addLog("onSettledOnEndTarget " + endTarget); - if (endTarget != NEW_TASK) { - InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); - } } /** @return Whether this was the task we were waiting to appear, and thus handled it. */ @@ -1219,11 +1225,9 @@ public abstract class AbsSwipeUpHandler, Q extends anim.addOnUpdateListener((r, p) -> { updateSysUiFlags(Math.max(p, mCurrentShift.value)); }); - final int cuj = InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME; anim.addAnimatorListener(new AnimationSuccessListener() { @Override public void onAnimationStart(Animator animation) { - InteractionJankMonitorWrapper.begin(cuj); if (mActivity != null) { removeLiveTileOverlay(); } @@ -1237,13 +1241,6 @@ public abstract class AbsSwipeUpHandler, Q extends // Make sure recents is in its final state maybeUpdateRecentsAttachedState(false); mActivityInterface.onSwipeUpToHomeComplete(mDeviceState); - InteractionJankMonitorWrapper.end(cuj); - } - - @Override - public void onAnimationCancel(Animator animation) { - super.onAnimationCancel(animation); - InteractionJankMonitorWrapper.cancel(cuj); } }); if (mRecentsAnimationTargets != null) { diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java index bc5e18dab1..646c5a0592 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java @@ -136,6 +136,7 @@ public class RecentsAnimationController { UI_HELPER_EXECUTOR.execute(() -> { mController.finish(toRecents, sendUserLeaveHint); InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); if (callback != null) { MAIN_EXECUTOR.execute(callback); }