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
This commit is contained in:
@@ -611,23 +611,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(), 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(), 0);
|
||||||
BackgroundThread.getHandler().removeCallbacks(mTimeoutRunnable);
|
BackgroundThread.getHandler().removeCallbacks(mTimeoutRunnable);
|
||||||
mTimeoutRunnable = null;
|
mTimeoutRunnable = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user