Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af7a9839 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "add LatencyTracker tracing cancel / timeout events" into udc-dev am: 2fe897d5

parents 55759c6e 2fe897d5
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -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;
        }
        }