@Implements(value=android.os.Trace.class) public class ShadowTrace extends java.lang.Object
Shadow implementation for 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 ShadowTrace.beginSection(String)
/ ShadowTrace.endSection()
sequences), but can be configured to do so by calling ShadowTrace.setCrashOnIncorrectUsage(boolean)
.
Constructor and Description |
---|
ShadowTrace() |
Modifier and Type | Method and Description |
---|---|
protected static void |
beginSection(java.lang.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 java.util.Deque<java.lang.String> |
getCurrentSections()
Returns a stack of the currently active trace sections.
|
static java.util.Queue<java.lang.String> |
getPreviousSections()
Returns a queue of all the previously active trace sections.
|
protected static boolean |
isTagEnabled(long traceTag) |
static void |
reset()
Resets internal lists of active trace sections.
|
protected static void |
setAppTracingAllowed(boolean appTracingAllowed) |
@Implementation(minSdk=18) protected static void beginSection(java.lang.String sectionName)
Starts a new trace section with given name.
@Implementation(minSdk=18) protected static void endSection()
Ends the most recent active trace section.
{@link
- AssertionError} if called without any active trace section.@Implementation(minSdk=18) protected static boolean isTagEnabled(long traceTag)
@Implementation(minSdk=18) protected static void setAppTracingAllowed(boolean appTracingAllowed)
public static java.util.Deque<java.lang.String> getCurrentSections()
Returns a stack of the currently active trace sections.
public static java.util.Queue<java.lang.String> getPreviousSections()
Returns a queue of all the previously active trace sections.
public static void doNotUseSetCrashOnIncorrectUsage(boolean crashOnIncorrectUsage)
Do not use this method unless absolutely necessary. Prefer fixing the tests instead.
Sets whether to crash on incorrect usage (e.g., calling endSection()
before beginSection(String)
. Default value - false
.
@Resetter public static void reset()
Resets internal lists of active trace sections.