Insert correct app transition events for recents anim

The transition delay will be the latency until all the leashes
were created etc. Thus, the actual latency is going to be in
WINDOWS_DRAWN_DELAY.

Also fix an issue where we inadvertently started a transition,
and then the transition logger was hanging.

Bug: 72967764
Test: Swipe up from home button, observe eventlog
Change-Id: I2b1fb7d9d694a629a33653c1fa3d5ed47f53de6b
diff --git a/services/core/java/com/android/server/am/ActivityMetricsLogger.java b/services/core/java/com/android/server/am/ActivityMetricsLogger.java
index 352b757..724dd3f 100644
--- a/services/core/java/com/android/server/am/ActivityMetricsLogger.java
+++ b/services/core/java/com/android/server/am/ActivityMetricsLogger.java
@@ -299,7 +299,7 @@
 
         final boolean otherWindowModesLaunching =
                 mWindowingModeTransitionInfo.size() > 0 && info == null;
-        if ((resultCode < 0 || launchedActivity == null || !processSwitch
+        if ((!isLoggableResultCode(resultCode) || launchedActivity == null || !processSwitch
                 || windowingMode == WINDOWING_MODE_UNDEFINED) && !otherWindowModesLaunching) {
 
             // Failed to launch or it was not a process switch, so we don't care about the timing.
@@ -322,6 +322,14 @@
     }
 
     /**
+     * @return True if we should start logging an event for an activity start that returned
+     *         {@code resultCode} and that we'll indeed get a windows drawn event.
+     */
+    private boolean isLoggableResultCode(int resultCode) {
+        return resultCode == START_SUCCESS || resultCode == START_TASK_TO_FRONT;
+    }
+
+    /**
      * Notifies the tracker that all windows of the app have been drawn.
      */
     void notifyWindowsDrawn(int windowingMode, long timestamp) {