Merge "Add NDK async begin/end & counter"

This commit is contained in:
John Reck
2018-12-06 21:43:18 +00:00
committed by Android (Google) Code Review
5 changed files with 21 additions and 6 deletions

View File

@@ -34592,7 +34592,7 @@ package android.os {
method public static void endAsyncSection(java.lang.String, int);
method public static void endSection();
method public static boolean isEnabled();
method public static void setCounter(java.lang.String, int);
method public static void setCounter(java.lang.String, long);
}
public class TransactionTooLargeException extends android.os.RemoteException {

View File

@@ -109,7 +109,7 @@ public final class Trace {
private static native void nativeSetTracingEnabled(boolean allowed);
@FastNative
private static native void nativeTraceCounter(long tag, String name, int value);
private static native void nativeTraceCounter(long tag, String name, long value);
@FastNative
private static native void nativeTraceBegin(long tag, String name);
@FastNative
@@ -365,7 +365,7 @@ public final class Trace {
* @param counterName The counter name to appear in the trace.
* @param counterValue The counter value.
*/
public static void setCounter(String counterName, int counterValue) {
public static void setCounter(String counterName, long counterValue) {
if (isTagEnabled(TRACE_TAG_APP)) {
nativeTraceCounter(TRACE_TAG_APP, counterName, counterValue);
}

View File

@@ -52,9 +52,9 @@ static jlong android_os_Trace_nativeGetEnabledTags(JNIEnv*, jclass) {
}
static void android_os_Trace_nativeTraceCounter(JNIEnv* env, jclass,
jlong tag, jstring nameStr, jint value) {
jlong tag, jstring nameStr, jlong value) {
withString(env, nameStr, [tag, value](char* str) {
atrace_int(tag, str, value);
atrace_int64(tag, str, value);
});
}
@@ -106,7 +106,7 @@ static const JNINativeMethod gTraceMethods[] = {
// ----------- @FastNative ----------------
{ "nativeTraceCounter",
"(JLjava/lang/String;I)V",
"(JLjava/lang/String;J)V",
(void*)android_os_Trace_nativeTraceCounter },
{ "nativeTraceBegin",
"(JLjava/lang/String;)V",

View File

@@ -229,6 +229,9 @@ LIBANDROID {
ATrace_beginSection; # introduced=23
ATrace_endSection; # introduced=23
ATrace_isEnabled; # introduced=23
ATrace_beginAsyncSection; # introduced=29
ATrace_endAsyncSection; # introduced=29
ATrace_setCounter; # introduced=29
android_getaddrinfofornetwork; # introduced=23
android_setprocnetwork; # introduced=23
android_setsocknetwork; # introduced=23

View File

@@ -28,3 +28,15 @@ void ATrace_beginSection(const char* sectionName) {
void ATrace_endSection() {
atrace_end(ATRACE_TAG_APP);
}
void ATrace_beginAsyncSection(const char* sectionName, int32_t cookie) {
atrace_async_begin(ATRACE_TAG_APP, sectionName, cookie);
}
void ATrace_endAsyncSection(const char* sectionName, int32_t cookie) {
atrace_async_end(ATRACE_TAG_APP, sectionName, cookie);
}
void ATrace_setCounter(const char* counterName, int64_t counterValue) {
atrace_int64(ATRACE_TAG_APP, counterName, counterValue);
}