From 90ed0f9b32d5cb2646d867df08831448cdde72f4 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 12 Apr 2024 19:08:56 +0800 Subject: [PATCH] Ensure that the recents start time is non-zero It was only assigned when using gesture navigation. When using non-gesture navigation, the calculation below in ActivityMetricsLogger will be (uptime - 0) which could be several hours or days. mSourceEventDelayMs = (int) (TimeUnit.NANOSECONDS.toMillis( launchingState.mStartUptimeNs) - sourceInfo.eventTimeMs); Because the start time was set right after GestureState is created, it can be simply set as the creation time of GestureState. So non-gesture navigation can provide the timestamp when handling OverviewCommandHelper.TYPE_TOGGLE. Bug: 206872204 Test: Use 3-button navigation to enter recent. The value of LatencyTracker should not be unexpected large. Change-Id: Ie661222822912e287d1ac295ccaf49e2086d909e --- quickstep/src/com/android/quickstep/GestureState.java | 7 ++----- .../src/com/android/quickstep/TouchInteractionService.java | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index d02909c527..94f734c7b7 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -30,6 +30,7 @@ import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET_NEW_TASK; import android.content.Intent; +import android.os.SystemClock; import android.view.MotionEvent; import android.view.RemoteAnimationTarget; @@ -182,7 +183,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL private HashMap mRecentsAnimationCanceledSnapshots; /** The time when the swipe up gesture is triggered. */ - private long mSwipeUpStartTimeMs; + private final long mSwipeUpStartTimeMs = SystemClock.uptimeMillis(); private boolean mHandlingAtomicEvent; @@ -508,10 +509,6 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL return null; } - void setSwipeUpStartTimeMs(long uptimeMs) { - mSwipeUpStartTimeMs = uptimeMs; - } - long getSwipeUpStartTimeMs() { return mSwipeUpStartTimeMs; } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index f2ee3f1483..954483cbce 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -753,7 +753,6 @@ public class TouchInteractionService extends Service { GestureState prevGestureState = new GestureState(mGestureState); GestureState newGestureState = createGestureState(mGestureState, getTrackpadGestureType(event)); - newGestureState.setSwipeUpStartTimeMs(SystemClock.uptimeMillis()); mConsumer.onConsumerAboutToBeSwitched(); mGestureState = newGestureState; mConsumer = newConsumer(prevGestureState, mGestureState, event);