Added Java bindings to async trace functions with track argument
Bug: 22119585 Test: atest TraceDevTest Change-Id: I0432763837670de97e6771a1d0fda33f8df14f39
This commit is contained in:
parent
4797e99e5f
commit
420bd3c28a
@ -136,6 +136,12 @@ public final class Trace {
|
||||
@FastNative
|
||||
private static native void nativeAsyncTraceEnd(long tag, String name, int cookie);
|
||||
@FastNative
|
||||
private static native void nativeAsyncTraceForTrackBegin(long tag,
|
||||
String trackName, String name, int cookie);
|
||||
@FastNative
|
||||
private static native void nativeAsyncTraceForTrackEnd(long tag,
|
||||
String trackName, String name, int cookie);
|
||||
@FastNative
|
||||
private static native void nativeInstant(long tag, String name);
|
||||
@FastNative
|
||||
private static native void nativeInstantForTrack(long tag, String trackName, String name);
|
||||
@ -271,6 +277,47 @@ 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
|
||||
* tag. This function operates exactly like {@link #asyncTraceBegin(long, String, int)},
|
||||
* except with the inclusion of a track name argument for where this method should appear.
|
||||
*
|
||||
* @param traceTag The trace tag.
|
||||
* @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 for distinguishing simultaneous events
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static void asyncTraceForTrackBegin(long traceTag,
|
||||
@NonNull String trackName, @NonNull String methodName, int cookie) {
|
||||
if (isTagEnabled(traceTag)) {
|
||||
nativeAsyncTraceForTrackBegin(traceTag, trackName, methodName, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a trace message to indicate that the current method has ended.
|
||||
* Must be called exactly once for each call to
|
||||
* {@link #asyncTraceForTrackBegin(long, String, String, int)}
|
||||
* using the same tag, track name, name and cookie.
|
||||
*
|
||||
* @param traceTag The trace tag.
|
||||
* @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 for distinguishing simultaneous events
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static void asyncTraceForTrackEnd(long traceTag,
|
||||
@NonNull String trackName, @NonNull String methodName, int cookie) {
|
||||
if (isTagEnabled(traceTag)) {
|
||||
nativeAsyncTraceForTrackEnd(traceTag, trackName, methodName, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a trace message to indicate that a given section of code was invoked.
|
||||
*
|
||||
|
@ -82,6 +82,26 @@ static void android_os_Trace_nativeAsyncTraceEnd(JNIEnv* env, jclass,
|
||||
});
|
||||
}
|
||||
|
||||
static void android_os_Trace_nativeAsyncTraceForTrackBegin(JNIEnv* env, jclass, jlong tag,
|
||||
jstring trackStr, jstring nameStr,
|
||||
jint cookie) {
|
||||
withString(env, trackStr, [env, tag, nameStr, cookie](char* track) {
|
||||
withString(env, nameStr, [tag, track, cookie](char* name) {
|
||||
atrace_async_for_track_begin(tag, track, name, cookie);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static void android_os_Trace_nativeAsyncTraceForTrackEnd(JNIEnv* env, jclass, jlong tag,
|
||||
jstring trackStr, jstring nameStr,
|
||||
jint cookie) {
|
||||
withString(env, trackStr, [env, tag, nameStr, cookie](char* track) {
|
||||
withString(env, nameStr, [tag, track, cookie](char* name) {
|
||||
atrace_async_for_track_end(tag, track, name, cookie);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static void android_os_Trace_nativeSetAppTracingAllowed(JNIEnv*, jclass, jboolean allowed) {
|
||||
atrace_update_tags();
|
||||
}
|
||||
@ -132,6 +152,12 @@ static const JNINativeMethod gTraceMethods[] = {
|
||||
{ "nativeAsyncTraceEnd",
|
||||
"(JLjava/lang/String;I)V",
|
||||
(void*)android_os_Trace_nativeAsyncTraceEnd },
|
||||
{ "nativeAsyncTraceForTrackBegin",
|
||||
"(JLjava/lang/String;Ljava/lang/String;I)V",
|
||||
(void*)android_os_Trace_nativeAsyncTraceForTrackBegin },
|
||||
{ "nativeAsyncTraceForTrackEnd",
|
||||
"(JLjava/lang/String;Ljava/lang/String;I)V",
|
||||
(void*)android_os_Trace_nativeAsyncTraceForTrackEnd },
|
||||
{ "nativeInstant",
|
||||
"(JLjava/lang/String;)V",
|
||||
(void*)android_os_Trace_nativeInstant },
|
||||
|
Loading…
x
Reference in New Issue
Block a user