summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Sum <esum@google.com> 2025-03-11 16:49:15 -0700
committer Eric Sum <esum@google.com> 2025-03-11 19:44:53 -0700
commitb6c1af8b35e627ee29eb04c6f3abff43656a639c (patch)
tree3dba1015cc278db5e6c57292ab5608dd1b0f60a4
parentaddf0e8fb0eea308f0263f2a43bb4f92044038e1 (diff)
Add ACTION_DESKTOP_MODE_EXIT_MODE latency.
This measures the delay from when the user provides input to exit desktop mode until the animation to exit desktop mode starts. "input" for this metric includes doing any of the following to switch an app to full screen mode: * Selecting the full screen button in an app handle's menu. * Dragging an app window's handle to the top of the screen. * Using a keyboard shortcut. Flag: EXEMPT metric change Bug: 390544490 Test: Run `statsd_testdrive 306` and ensure that latency metric is reported. Change-Id: Iaa1c86a85e1a1d7b0f460a8b758ece16bdf9a0cb
-rw-r--r--core/java/com/android/internal/util/LatencyTracker.java16
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ExitDesktopTaskTransitionHandler.java9
2 files changed, 25 insertions, 0 deletions
diff --git a/core/java/com/android/internal/util/LatencyTracker.java b/core/java/com/android/internal/util/LatencyTracker.java
index 33794a59fa21..ac2c51cfe888 100644
--- a/core/java/com/android/internal/util/LatencyTracker.java
+++ b/core/java/com/android/internal/util/LatencyTracker.java
@@ -24,6 +24,7 @@ import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPOR
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_CHECK_CREDENTIAL_UNLOCKED;
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG;
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_MENU;
+import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_EXIT_MODE;
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_EXPAND_PANEL;
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_FACE_WAKE_AND_UNLOCK;
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_FINGERPRINT_WAKE_AND_UNLOCK;
@@ -290,6 +291,16 @@ public class LatencyTracker {
*/
public static final int ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_MENU = 31;
+ /**
+ * Time it takes for the "exit desktop" mode animation to begin after the user provides input.
+ * <p>
+ * Starts when the user provides input to exit desktop mode and enter full screen mode for an
+ * app. This including selecting the full screen button in an app handle's menu, dragging an
+ * app's window handle to the top of the screen, and using the appropriate keyboard shortcut.
+ * Ends when the animation to exit desktop mode begins.
+ */
+ public static final int ACTION_DESKTOP_MODE_EXIT_MODE = 32;
+
private static final int[] ACTIONS_ALL = {
ACTION_EXPAND_PANEL,
ACTION_TOGGLE_RECENTS,
@@ -323,6 +334,7 @@ public class LatencyTracker {
ACTION_SHADE_WINDOW_DISPLAY_CHANGE,
ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG,
ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_MENU,
+ ACTION_DESKTOP_MODE_EXIT_MODE,
};
/** @hide */
@@ -359,6 +371,7 @@ public class LatencyTracker {
ACTION_SHADE_WINDOW_DISPLAY_CHANGE,
ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG,
ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_MENU,
+ ACTION_DESKTOP_MODE_EXIT_MODE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface Action {}
@@ -397,6 +410,7 @@ public class LatencyTracker {
UIACTION_LATENCY_REPORTED__ACTION__ACTION_SHADE_WINDOW_DISPLAY_CHANGE,
UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG,
UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_MENU,
+ UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_EXIT_MODE,
};
private final Object mLock = new Object();
@@ -601,6 +615,8 @@ public class LatencyTracker {
return "ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG";
case UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_MENU:
return "ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_MENU";
+ case UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_EXIT_MODE:
+ return "ACTION_DESKTOP_MODE_EXIT_MODE";
default:
throw new IllegalArgumentException("Invalid action");
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ExitDesktopTaskTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ExitDesktopTaskTransitionHandler.java
index 95cc1e68ac11..f382632ff790 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ExitDesktopTaskTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ExitDesktopTaskTransitionHandler.java
@@ -46,6 +46,7 @@ import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.Cuj;
import com.android.internal.jank.InteractionJankMonitor;
+import com.android.internal.util.LatencyTracker;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource;
import com.android.wm.shell.transition.Transitions;
@@ -68,6 +69,7 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
private final Context mContext;
private final Transitions mTransitions;
private final InteractionJankMonitor mInteractionJankMonitor;
+ private final LatencyTracker mLatencyTracker;
@ShellMainThread
private final Handler mHandler;
private final List<IBinder> mPendingTransitionTokens = new ArrayList<>();
@@ -95,6 +97,7 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
mTransactionSupplier = supplier;
mContext = context;
mInteractionJankMonitor = interactionJankMonitor;
+ mLatencyTracker = LatencyTracker.getInstance(mContext);
mHandler = handler;
}
@@ -109,6 +112,7 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
public IBinder startTransition(@NonNull DesktopModeTransitionSource transitionSource,
@NonNull WindowContainerTransaction wct, Point position,
Function0<Unit> onAnimationEndCallback) {
+ mLatencyTracker.onActionStart(LatencyTracker.ACTION_DESKTOP_MODE_EXIT_MODE);
mPosition = position;
mOnAnimationFinishedCallback = onAnimationEndCallback;
final IBinder token = mTransitions.startTransition(getExitTransitionType(transitionSource),
@@ -141,6 +145,11 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
mPendingTransitionTokens.remove(transition);
+
+ if (transitionHandled) {
+ mLatencyTracker.onActionEnd(LatencyTracker.ACTION_DESKTOP_MODE_EXIT_MODE);
+ }
+
return transitionHandled;
}