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

Commit e06b6a83 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Dump elapsed time with jank events

Allows to more accurately associate jank events with other traces. Particularly useful for FaaS to associate with the transition trace.

Bug: 267482772
Test: Run tagged CUJ and make sure the timestamp appears in the event logs
Change-Id: I36f4f5748c1b09c32293ec972a11693d353b215f
parent 53fd5b51
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@
option java_package com.android.internal.jank;

# Marks a request to start tracing a CUJ. Doesn't mean the request was executed.
37001 jank_cuj_events_begin_request (CUJ Type|1|5)
37001 jank_cuj_events_begin_request (CUJ Type|1|5),(Elapsed Time Ns|2|3),(Uptime Ns|2|3)
# Marks a request to end tracing a CUJ. Doesn't mean the request was executed.
37002 jank_cuj_events_end_request (CUJ Type|1|5)
37002 jank_cuj_events_end_request (CUJ Type|1|5),(Elapsed Time Ns|2|3),(Uptime Time Ns|2|3)
# Marks a request to cancel tracing a CUJ. Doesn't mean the request was executed.
37003 jank_cuj_events_cancel_request (CUJ Type|1|5)
37003 jank_cuj_events_cancel_request (CUJ Type|1|5),(Elapsed Time Ns|2|3),(Uptime Time Ns|2|3)
+7 −3
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ import android.os.Build;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.SystemClock;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
@@ -556,7 +557,8 @@ public class InteractionJankMonitor {
    public boolean begin(@NonNull Configuration.Builder builder) {
        try {
            final Configuration config = builder.build();
            EventLogTags.writeJankCujEventsBeginRequest(config.mCujType);
            EventLogTags.writeJankCujEventsBeginRequest(
                    config.mCujType, SystemClock.elapsedRealtimeNanos(), SystemClock.uptimeNanos());
            final TrackerResult result = new TrackerResult();
            final boolean success = config.getHandler().runWithScissors(
                    () -> result.mResult = beginInternal(config), EXECUTOR_TASK_TIMEOUT);
@@ -630,7 +632,8 @@ public class InteractionJankMonitor {
     * @return boolean true if the tracker is ended successfully, false otherwise.
     */
    public boolean end(@CujType int cujType) {
        EventLogTags.writeJankCujEventsEndRequest(cujType);
        EventLogTags.writeJankCujEventsEndRequest(cujType, SystemClock.elapsedRealtimeNanos(),
                SystemClock.uptimeNanos());
        FrameTracker tracker = getTracker(cujType);
        // Skip this call since we haven't started a trace yet.
        if (tracker == null) return false;
@@ -668,7 +671,8 @@ public class InteractionJankMonitor {
     * @return boolean true if the tracker is cancelled successfully, false otherwise.
     */
    public boolean cancel(@CujType int cujType) {
        EventLogTags.writeJankCujEventsCancelRequest(cujType);
        EventLogTags.writeJankCujEventsCancelRequest(cujType, SystemClock.elapsedRealtimeNanos(),
                SystemClock.uptimeNanos());
        return cancel(cujType, REASON_CANCEL_NORMAL);
    }