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

Commit 735d79da authored by Ethan Lee's avatar Ethan Lee
Browse files

Add asyncTraceForTrackBegin and asyncTraceForTrackEnd System APIs

- Upgrade these APIs from hidden to System API.
- These tracks will appear under TRACE_TAG_APP, which is currently hidden.

Test: m -j
Bug: 407831889
Flag: android.os.async_trace_for_track
API-Coverage-Bug: 409782350
FCRS_CODE : m9bwobgaccsddp

Change-Id: Ib7d9e0257c8f45455e590e2bedc3ae60a324cf3b
parent 2047bdf1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -11589,6 +11589,8 @@ package android.os {
  }
  public final class Trace {
    method @FlaggedApi("android.os.async_trace_for_track") public static void asyncTraceForTrackBegin(@NonNull String, @NonNull String, int);
    method @FlaggedApi("android.os.async_trace_for_track") public static void asyncTraceForTrackEnd(@NonNull String, int);
    field public static final long TRACE_TAG_AIDL = 16777216L; // 0x1000000L
  }
+45 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.os;

import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
@@ -387,6 +388,29 @@ public final class Trace {
        }
    }

    /**
     * Writes a trace message to indicate that a given section of code has
     * begun. Must be followed by a call to {@link #asyncTraceForTrackEnd} using the same
     * track name and cookie.
     *
     * Events with the same trackName and cookie nest inside each other in the
     * same way as calls to {@link #traceBegin(long, String)} and
     * {@link #traceEnd(long)}.
     *
     * @param trackName  The track where the event should appear in the trace.
     * @param methodName The method name to appear in the trace.
     * @param cookie     Unique identifier used for nesting events on a single
     *                   track. Events which overlap without nesting on the same
     *                   track must have different values for cookie.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_ASYNC_TRACE_FOR_TRACK)
    public static void asyncTraceForTrackBegin(
            @NonNull String trackName, @NonNull String methodName, int cookie) {
        asyncTraceForTrackBegin(TRACE_TAG_APP, trackName, methodName, cookie);
    }

    /**
     * Writes a trace message to indicate that the current method has ended.
     * Must be called exactly once for each call to
@@ -411,6 +435,27 @@ public final class Trace {
        }
    }

    /**
     * Writes a trace message to indicate that the current method has ended.
     * Must be called exactly once for each call to
     * {@link #asyncTraceForTrackBegin(String, String, int)}
     * using the same track name, and cookie.
     *
     * See the documentation for {@link #asyncTraceForTrackBegin(String, String, int)}.
     * for intended usage of this method.
     *
     * @param trackName The track where the event should appear in the trace.
     * @param cookie    Unique identifier used for nesting events on a single
     *                  track. Events which overlap without nesting on the same
     *                  track must have different values for cookie.
     * @hide
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_ASYNC_TRACE_FOR_TRACK)
    public static void asyncTraceForTrackEnd(@NonNull String trackName, int cookie) {
        asyncTraceForTrackEnd(TRACE_TAG_APP, trackName, cookie);
    }

    /**
     * Writes a trace message to indicate that a given section of code was invoked.
     *
+8 −0
Original line number Diff line number Diff line
@@ -147,6 +147,14 @@ flag {
     bug: "361799815"
}

flag {
    name: "async_trace_for_track"
    is_exported: true
    namespace: "perfetto"
    description: "Enable async trace for track."
    bug: "407831889"
}

flag {
    name: "battery_part_status_api"
    is_exported: true