summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nicholas Ambur <nambur@google.com> 2023-02-13 19:00:50 +0000
committer Nicholas Ambur <nambur@google.com> 2023-03-22 20:55:35 +0000
commitc37e3adeffd4e79193c9fc23f2795a043d673ab9 (patch)
tree2fc879949444686d4f3e843ac7166fd62597af56
parent614f8384db4d5fa9cd275465a4c59c4a86f0780f (diff)
add LatencyTracker tracing cancel / timeout events
Bug: 265850090 Test: manual invoke hotword trigger collecting trace and verify in Perfetto UI that trace has cancel and timeout events Change-Id: Ie5acefe043575b198ce1fbd1526cc82116649cb3 (cherry picked from commit 3f793d7daa59e5a4b94fcf8f54ba669a0a505764) Merged-In: Ie5acefe043575b198ce1fbd1526cc82116649cb3
-rw-r--r--core/java/com/android/internal/util/LatencyTracker.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/java/com/android/internal/util/LatencyTracker.java b/core/java/com/android/internal/util/LatencyTracker.java
index fe08083282c5..c933bfd5b372 100644
--- a/core/java/com/android/internal/util/LatencyTracker.java
+++ b/core/java/com/android/internal/util/LatencyTracker.java
@@ -605,23 +605,27 @@ public class LatencyTracker {
void begin(@NonNull Runnable timeoutAction) {
mStartRtc = SystemClock.elapsedRealtime();
- Trace.asyncTraceBegin(TRACE_TAG_APP, traceName(), 0);
+ Trace.asyncTraceForTrackBegin(TRACE_TAG_APP, traceName(), traceName(), 0);
// start counting timeout.
- mTimeoutRunnable = timeoutAction;
+ mTimeoutRunnable = () -> {
+ Trace.instantForTrack(TRACE_TAG_APP, traceName(), "timeout");
+ timeoutAction.run();
+ };
BackgroundThread.getHandler()
.postDelayed(mTimeoutRunnable, TimeUnit.SECONDS.toMillis(15));
}
void end() {
mEndRtc = SystemClock.elapsedRealtime();
- Trace.asyncTraceEnd(TRACE_TAG_APP, traceName(), 0);
+ Trace.asyncTraceForTrackEnd(TRACE_TAG_APP, traceName(), "end", 0);
BackgroundThread.getHandler().removeCallbacks(mTimeoutRunnable);
mTimeoutRunnable = null;
}
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);
mTimeoutRunnable = null;
}