Methods Summary |
---|
public static void | asyncTraceBegin(long traceTag, java.lang.String methodName, int cookie)Writes a trace message to indicate that a given section of code has
begun. Must be followed by a call to {@link #asyncTraceEnd} using the same
tag. Unlike {@link #traceBegin(long, String)} and {@link #traceEnd(long)},
asynchronous events do not need to be nested. The name and cookie used to
begin an event must be used to end it.
if (isTagEnabled(traceTag)) {
nativeAsyncTraceBegin(traceTag, methodName, cookie);
}
|
public static void | asyncTraceEnd(long traceTag, java.lang.String methodName, int cookie)Writes a trace message to indicate that the current method has ended.
Must be called exactly once for each call to {@link #asyncTraceBegin(long, String, int)}
using the same tag, name and cookie.
if (isTagEnabled(traceTag)) {
nativeAsyncTraceEnd(traceTag, methodName, cookie);
}
|
public static void | beginSection(java.lang.String sectionName)Writes a trace message to indicate that a given section of code has begun. This call must
be followed by a corresponding call to {@link #endSection()} on the same thread.
At this time the vertical bar character '|', newline character '\n', and
null character '\0' are used internally by the tracing mechanism. If sectionName contains
these characters they will be replaced with a space character in the trace.
if (isTagEnabled(TRACE_TAG_APP)) {
if (sectionName.length() > MAX_SECTION_NAME_LEN) {
throw new IllegalArgumentException("sectionName is too long");
}
nativeTraceBegin(TRACE_TAG_APP, sectionName);
}
|
private static long | cacheEnabledTags()Caches a copy of the enabled-tag bits. The "master" copy is held by the native code,
and comes from the PROPERTY_TRACE_TAG_ENABLEFLAGS property.
If the native code hasn't yet read the property, we will cause it to do one-time
initialization. We don't want to do this during class init, because this class is
preloaded, so all apps would be stuck with whatever the zygote saw. (The zygote
doesn't see the system-property update broadcasts.)
We want to defer initialization until the first use by an app, post-zygote.
We're okay if multiple threads call here simultaneously -- the native state is
synchronized, and sEnabledTags is volatile (prevents word tearing).
long tags = nativeGetEnabledTags();
sEnabledTags = tags;
return tags;
|
public static void | endSection()Writes a trace message to indicate that a given section of code has ended. This call must
be preceeded by a corresponding call to {@link #beginSection(String)}. Calling this method
will mark the end of the most recently begun section of code, so care must be taken to
ensure that beginSection / endSection pairs are properly nested and called from the same
thread.
if (isTagEnabled(TRACE_TAG_APP)) {
nativeTraceEnd(TRACE_TAG_APP);
}
|
public static boolean | isTagEnabled(long traceTag)Returns true if a trace tag is enabled.
long tags = sEnabledTags;
if (tags == TRACE_TAG_NOT_READY) {
tags = cacheEnabledTags();
}
return (tags & traceTag) != 0;
|
private static native void | nativeAsyncTraceBegin(long tag, java.lang.String name, int cookie)
|
private static native void | nativeAsyncTraceEnd(long tag, java.lang.String name, int cookie)
|
private static native long | nativeGetEnabledTags()
|
private static native void | nativeSetAppTracingAllowed(boolean allowed)
|
private static native void | nativeSetTracingEnabled(boolean allowed)
|
private static native void | nativeTraceBegin(long tag, java.lang.String name)
|
private static native void | nativeTraceCounter(long tag, java.lang.String name, int value)
|
private static native void | nativeTraceEnd(long tag)
|
public static void | setAppTracingAllowed(boolean allowed)Set whether application tracing is allowed for this process. This is intended to be set
once at application start-up time based on whether the application is debuggable.
nativeSetAppTracingAllowed(allowed);
// Setting whether app tracing is allowed may change the tags, so we update the cached
// tags here.
cacheEnabledTags();
|
public static void | setTracingEnabled(boolean enabled)Set whether tracing is enabled in this process. Tracing is disabled shortly after Zygote
initializes and re-enabled after processes fork from Zygote. This is done because Zygote
has no way to be notified about changes to the tracing tags, and if Zygote ever reads and
caches the tracing tags, forked processes will inherit those stale tags.
nativeSetTracingEnabled(enabled);
// Setting whether tracing is enabled may change the tags, so we update the cached tags
// here.
cacheEnabledTags();
|
public static void | traceBegin(long traceTag, java.lang.String methodName)Writes a trace message to indicate that a given section of code has
begun. Must be followed by a call to {@link #traceEnd} using the same
tag.
if (isTagEnabled(traceTag)) {
nativeTraceBegin(traceTag, methodName);
}
|
public static void | traceCounter(long traceTag, java.lang.String counterName, int counterValue)Writes trace message to indicate the value of a given counter.
if (isTagEnabled(traceTag)) {
nativeTraceCounter(traceTag, counterName, counterValue);
}
|
public static void | traceEnd(long traceTag)Writes a trace message to indicate that the current method has ended.
Must be called exactly once for each call to {@link #traceBegin} using the same tag.
if (isTagEnabled(traceTag)) {
nativeTraceEnd(traceTag);
}
|