summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Sum <esum@google.com> 2025-02-10 20:59:04 -0800
committer Eric Sum <esum@google.com> 2025-02-13 11:04:44 -0800
commit686af717d8dd5700be641c76f73dfdfab63bdf49 (patch)
treeb2d7c92319a7f87000a2bf1902739eaadf484b41
parent852ed63009f4683ccb8b11a998aa15ce80c3e83f (diff)
Add ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG latency.
This measures the delay between steps 2 and 3 in the following sequence: 1) Drag an app's handle while it's in full screen mode towards the middle of the screen to enter desktop mode. 2) Release the drag. 3) Window's bounds start animating to their new position, and the device enters desktop mode. In a past bug, this delay was large. It has since been fixed to be acceptable, but this latency is being tracked to catch any other cases that may be missed and potential future regressoins. Flag: EXEMPT metric change Bug: 381408940 Test: Put tangorpro in HSUM mode: `adb shell cmd user set-system-user-mode-emulation headless` Run `statsd_testdrive 306` and ensure that latency metric is reported. This was done with `enable_desktop_wallpaper_activity_for_system_user` enabled and disabled. The latency was close to 1 second with that flag disabled and ~100 milliseconds with that flag enabled. This is expected. atest DragToDesktopTransitionHandlerTest DesktopTasksControllerTest Change-Id: Ia523734ce44588a52166da7bec979bf7e049d3e3
-rw-r--r--core/java/com/android/internal/util/LatencyTracker.java18
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt12
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt5
3 files changed, 30 insertions, 5 deletions
diff --git a/core/java/com/android/internal/util/LatencyTracker.java b/core/java/com/android/internal/util/LatencyTracker.java
index f443b0adcb9d..c120e67dfb0d 100644
--- a/core/java/com/android/internal/util/LatencyTracker.java
+++ b/core/java/com/android/internal/util/LatencyTracker.java
@@ -22,6 +22,7 @@ import static android.provider.DeviceConfig.NAMESPACE_LATENCY_TRACKER;
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_BACK_SYSTEM_ANIMATION;
import static com.android.internal.util.FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_CHECK_CREDENTIAL;
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_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;
@@ -266,6 +267,15 @@ public class LatencyTracker {
*/
public static final int ACTION_SHADE_WINDOW_DISPLAY_CHANGE = 29;
+ /**
+ * Applicable when the user drags a full screen app's handle into the desktop drop zone to enter
+ * desktop mode. This measure the time from when the user releases their finger in the drop zone
+ * to when the animation for entering desktop mode visually begins. During this period, the
+ * home task and app headers for each window are initialized. Both have historically been
+ * expensive. See b/381396057 and b/360452034 respectively.
+ */
+ public static final int ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG = 30;
+
private static final int[] ACTIONS_ALL = {
ACTION_EXPAND_PANEL,
ACTION_TOGGLE_RECENTS,
@@ -297,6 +307,7 @@ public class LatencyTracker {
ACTION_NOTIFICATIONS_HIDDEN_FOR_MEASURE_WITH_SHADE_OPEN,
ACTION_KEYGUARD_FACE_UNLOCK_TO_HOME,
ACTION_SHADE_WINDOW_DISPLAY_CHANGE,
+ ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG,
};
/** @hide */
@@ -331,10 +342,10 @@ public class LatencyTracker {
ACTION_NOTIFICATIONS_HIDDEN_FOR_MEASURE_WITH_SHADE_OPEN,
ACTION_KEYGUARD_FACE_UNLOCK_TO_HOME,
ACTION_SHADE_WINDOW_DISPLAY_CHANGE,
+ ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG,
})
@Retention(RetentionPolicy.SOURCE)
- public @interface Action {
- }
+ public @interface Action {}
@VisibleForTesting
public static final int[] STATSD_ACTION = new int[] {
@@ -368,6 +379,7 @@ public class LatencyTracker {
UIACTION_LATENCY_REPORTED__ACTION__ACTION_NOTIFICATIONS_HIDDEN_FOR_MEASURE_WITH_SHADE_OPEN,
UIACTION_LATENCY_REPORTED__ACTION__ACTION_KEYGUARD_FACE_UNLOCK_TO_HOME,
UIACTION_LATENCY_REPORTED__ACTION__ACTION_SHADE_WINDOW_DISPLAY_CHANGE,
+ UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG,
};
private final Object mLock = new Object();
@@ -568,6 +580,8 @@ public class LatencyTracker {
return "ACTION_KEYGUARD_FACE_UNLOCK_TO_HOME";
case UIACTION_LATENCY_REPORTED__ACTION__ACTION_SHADE_WINDOW_DISPLAY_CHANGE:
return "ACTION_SHADE_WINDOW_DISPLAY_CHANGE";
+ case UIACTION_LATENCY_REPORTED__ACTION__ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG:
+ return "ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG";
default:
throw new IllegalArgumentException("Invalid action");
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
index c42d8dde0093..098108aebf17 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
@@ -71,6 +71,7 @@ import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELE
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_SNAP_RESIZE
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.protolog.ProtoLog
+import com.android.internal.util.LatencyTracker
import com.android.window.flags.Flags
import com.android.wm.shell.Flags.enableFlexibleSplit
import com.android.wm.shell.R
@@ -736,9 +737,9 @@ class DesktopTasksController(
desktopModeEnterExitTransitionListener?.onEnterDesktopModeTransitionStarted(
DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS.toInt()
)
- transition?.let {
- taskIdToMinimize?.let { taskId ->
- addPendingMinimizeTransition(it, taskId, MinimizeReason.TASK_LIMIT)
+ if (transition != null) {
+ taskIdToMinimize?.let {
+ addPendingMinimizeTransition(transition, it, MinimizeReason.TASK_LIMIT)
}
exitResult.asExit()?.runOnTransitionStart?.invoke(transition)
if (Flags.enableMultipleDesktopsBackend()) {
@@ -753,6 +754,9 @@ class DesktopTasksController(
} else {
taskRepository.setActiveDesk(displayId = taskInfo.displayId, deskId = deskId)
}
+ } else {
+ LatencyTracker.getInstance(context)
+ .onActionCancel(LatencyTracker.ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG)
}
}
@@ -2938,6 +2942,8 @@ class DesktopTasksController(
val indicatorType = indicator.updateIndicatorType(inputCoordinates)
when (indicatorType) {
IndicatorType.TO_DESKTOP_INDICATOR -> {
+ LatencyTracker.getInstance(context)
+ .onActionStart(LatencyTracker.ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG)
// Start a new jank interaction for the drag release to desktop window animation.
interactionJankMonitor.begin(
taskSurface,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
index fc29498291da..c9c5bed5d37f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
@@ -35,6 +35,7 @@ import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELEASE
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.protolog.ProtoLog
+import com.android.internal.util.LatencyTracker
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.animation.FloatProperties
import com.android.wm.shell.bubbles.BubbleController
@@ -558,8 +559,12 @@ sealed class DragToDesktopTransitionHandler(
)
// Call finishCallback to merge animation before startTransitionFinishCb is called
finishCallback.onTransitionFinished(/* wct= */ null)
+ LatencyTracker.getInstance(context)
+ .onActionEnd(LatencyTracker.ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG)
animateEndDragToDesktop(startTransaction = startT, startTransitionFinishCb)
} else if (isCancelTransition) {
+ LatencyTracker.getInstance(context)
+ .onActionCancel(LatencyTracker.ACTION_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG)
info.changes.forEach { change ->
startT.show(change.leash)
startTransactionFinishT.show(change.leash)