@Implements(android.os.Trace.class) public class ShadowTrace extends Object
Trace, which stores the traces locally in arrays (unlike the
real implementation) and allows reading them.
The shadow doesn't enforce the constrains by default (e.g., null section names, or incorrect {@link ShadowTrace.beginSection(String)} / {@link ShadowTrace.endSection()} sequences), but can be configured to do so by calling {@link ShadowTrace.setCrashOnIncorrectUsage(boolean)}.
| Constructor | Description |
|---|---|
ShadowTrace() |
| Modifier and Type | Method | Description |
|---|---|---|
protected static void |
beginSection(String sectionName) |
Starts a new trace section with given name.
|
static void |
doNotUseSetCrashOnIncorrectUsage(boolean crashOnIncorrectUsage) |
Do not use this method unless absolutely necessary.
|
protected static void |
endSection() |
Ends the most recent active trace section.
|
static Deque<String> |
getCurrentSections() |
Returns a stack of the currently active trace sections for the current thread.
|
static Queue<String> |
getPreviousSections() |
Returns a queue of all the previously active trace sections for the current thread.
|
protected static boolean |
isEnabled() |
Returns whether systrace is enabled.
|
protected static boolean |
isTagEnabled(long traceTag) |
|
static void |
reset() |
Resets internal lists of active trace sections.
|
protected static void |
setAppTracingAllowed(boolean appTracingAllowed) |
|
static void |
setEnabled(boolean enabled) |
Sets the systrace to enabled or disabled.
|
@Implementation(minSdk=18) protected static void beginSection(String sectionName)
@Implementation(minSdk=18) protected static void endSection()
@Implementation(minSdk=18) protected static boolean isTagEnabled(long traceTag)
@Implementation(minSdk=18) protected static void setAppTracingAllowed(boolean appTracingAllowed)
@Implementation(minSdk=29) protected static boolean isEnabled()
public static void setEnabled(boolean enabled)
public static Deque<String> getCurrentSections()
public static Queue<String> getPreviousSections()
public static void doNotUseSetCrashOnIncorrectUsage(boolean crashOnIncorrectUsage)
Sets whether to crash on incorrect usage (e.g., calling endSection() before beginSection(java.lang.String). Default value - false.
@Resetter public static void reset()