add LatencyTracker tracing cancel / timeout events am: c37e3adeff

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22162089

Change-Id: I448f9b72b213e31311ecaff6c87d84d032bf87a6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Nicholas Ambur
2023-03-23 20:08:56 +00:00
committed by Automerger Merge Worker

View File

@@ -605,23 +605,27 @@ public class LatencyTracker {
void begin(@NonNull Runnable timeoutAction) { void begin(@NonNull Runnable timeoutAction) {
mStartRtc = SystemClock.elapsedRealtime(); mStartRtc = SystemClock.elapsedRealtime();
Trace.asyncTraceBegin(TRACE_TAG_APP, traceName(), 0); Trace.asyncTraceForTrackBegin(TRACE_TAG_APP, traceName(), traceName(), 0);
// start counting timeout. // start counting timeout.
mTimeoutRunnable = timeoutAction; mTimeoutRunnable = () -> {
Trace.instantForTrack(TRACE_TAG_APP, traceName(), "timeout");
timeoutAction.run();
};
BackgroundThread.getHandler() BackgroundThread.getHandler()
.postDelayed(mTimeoutRunnable, TimeUnit.SECONDS.toMillis(15)); .postDelayed(mTimeoutRunnable, TimeUnit.SECONDS.toMillis(15));
} }
void end() { void end() {
mEndRtc = SystemClock.elapsedRealtime(); mEndRtc = SystemClock.elapsedRealtime();
Trace.asyncTraceEnd(TRACE_TAG_APP, traceName(), 0); Trace.asyncTraceForTrackEnd(TRACE_TAG_APP, traceName(), "end", 0);
BackgroundThread.getHandler().removeCallbacks(mTimeoutRunnable); BackgroundThread.getHandler().removeCallbacks(mTimeoutRunnable);
mTimeoutRunnable = null; mTimeoutRunnable = null;
} }
void cancel() { void cancel() {
Trace.asyncTraceEnd(TRACE_TAG_APP, traceName(), 0); Trace.instantForTrack(TRACE_TAG_APP, traceName(), "cancel");
Trace.asyncTraceForTrackEnd(TRACE_TAG_APP, traceName(), "cancel", 0);
BackgroundThread.getHandler().removeCallbacks(mTimeoutRunnable); BackgroundThread.getHandler().removeCallbacks(mTimeoutRunnable);
mTimeoutRunnable = null; mTimeoutRunnable = null;
} }