public final class Trace extends Object
This tracing mechanism is independent of the method tracing mechanism
offered by Debug.startMethodTracing()
. In particular, it enables
tracing of events that occur across multiple processes.
For information about using the Systrace tool, read Analyzing Display and Performance with Systrace.
Modifier and Type | Field and Description |
---|---|
static long |
TRACE_TAG_ACTIVITY_MANAGER |
static long |
TRACE_TAG_ALWAYS |
static long |
TRACE_TAG_APP |
static long |
TRACE_TAG_AUDIO |
static long |
TRACE_TAG_BIONIC |
static long |
TRACE_TAG_CAMERA |
static long |
TRACE_TAG_DALVIK |
static long |
TRACE_TAG_DATABASE |
static long |
TRACE_TAG_GRAPHICS |
static long |
TRACE_TAG_HAL |
static long |
TRACE_TAG_INPUT |
static long |
TRACE_TAG_NETWORK |
static long |
TRACE_TAG_NEVER |
static long |
TRACE_TAG_PACKAGE_MANAGER |
static long |
TRACE_TAG_POWER |
static long |
TRACE_TAG_RESOURCES |
static long |
TRACE_TAG_RS |
static long |
TRACE_TAG_SYNC_MANAGER |
static long |
TRACE_TAG_SYSTEM_SERVER |
static long |
TRACE_TAG_VIDEO |
static long |
TRACE_TAG_VIEW |
static long |
TRACE_TAG_WEBVIEW |
static long |
TRACE_TAG_WINDOW_MANAGER |
Modifier and Type | Method and Description |
---|---|
static void |
asyncTraceBegin(long traceTag,
String methodName,
int cookie)
Writes a trace message to indicate that a given section of code has
begun.
|
static void |
asyncTraceEnd(long traceTag,
String methodName,
int cookie)
Writes a trace message to indicate that the current method has ended.
|
static void |
beginSection(String sectionName)
Writes a trace message to indicate that a given section of code has begun.
|
static void |
endSection()
Writes a trace message to indicate that a given section of code has ended.
|
static boolean |
isTagEnabled(long traceTag)
Returns true if a trace tag is enabled.
|
static void |
setAppTracingAllowed(boolean allowed)
Set whether application tracing is allowed for this process.
|
static void |
setTracingEnabled(boolean enabled)
Set whether tracing is enabled in this process.
|
static void |
traceBegin(long traceTag,
String methodName)
Writes a trace message to indicate that a given section of code has
begun.
|
static void |
traceCounter(long traceTag,
String counterName,
int counterValue)
Writes trace message to indicate the value of a given counter.
|
static void |
traceEnd(long traceTag)
Writes a trace message to indicate that the current method has ended.
|
public static final long TRACE_TAG_NEVER
public static final long TRACE_TAG_ALWAYS
public static final long TRACE_TAG_GRAPHICS
public static final long TRACE_TAG_INPUT
public static final long TRACE_TAG_VIEW
public static final long TRACE_TAG_WEBVIEW
public static final long TRACE_TAG_WINDOW_MANAGER
public static final long TRACE_TAG_ACTIVITY_MANAGER
public static final long TRACE_TAG_SYNC_MANAGER
public static final long TRACE_TAG_AUDIO
public static final long TRACE_TAG_VIDEO
public static final long TRACE_TAG_CAMERA
public static final long TRACE_TAG_HAL
public static final long TRACE_TAG_APP
public static final long TRACE_TAG_RESOURCES
public static final long TRACE_TAG_DALVIK
public static final long TRACE_TAG_RS
public static final long TRACE_TAG_BIONIC
public static final long TRACE_TAG_POWER
public static final long TRACE_TAG_PACKAGE_MANAGER
public static final long TRACE_TAG_SYSTEM_SERVER
public static final long TRACE_TAG_DATABASE
public static final long TRACE_TAG_NETWORK
public static boolean isTagEnabled(long traceTag)
traceTag
- The trace tag to check.public static void traceCounter(long traceTag, String counterName, int counterValue)
traceTag
- The trace tag.counterName
- The counter name to appear in the trace.counterValue
- The counter value.public static void setAppTracingAllowed(boolean allowed)
public static void setTracingEnabled(boolean enabled)
public static void traceBegin(long traceTag, String methodName)
traceEnd(long)
using the same
tag.traceTag
- The trace tag.methodName
- The method name to appear in the trace.public static void traceEnd(long traceTag)
traceBegin(long, java.lang.String)
using the same tag.traceTag
- The trace tag.public static void asyncTraceBegin(long traceTag, String methodName, int cookie)
asyncTraceEnd(long, java.lang.String, int)
using the same
tag. Unlike traceBegin(long, String)
and 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.traceTag
- The trace tag.methodName
- The method name to appear in the trace.cookie
- Unique identifier for distinguishing simultaneous eventspublic static void asyncTraceEnd(long traceTag, String methodName, int cookie)
asyncTraceBegin(long, String, int)
using the same tag, name and cookie.traceTag
- The trace tag.methodName
- The method name to appear in the trace.cookie
- Unique identifier for distinguishing simultaneous eventspublic static void beginSection(String sectionName)
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.
sectionName
- The name of the code section to appear in the trace. This may be at
most 127 Unicode code units long.public static void endSection()
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.