diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2010-11-16 13:33:06 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-16 13:33:06 -0800 |
commit | ba22d21c3a8efc05a0505c4a32c2cf6e1b94dd62 (patch) | |
tree | 8244d4ab40e9b56a5c8e1b89caafca1f0c6ef28b /core | |
parent | 0046bd8ea6f56b632fd7b9c4c33e22f57232bcbc (diff) | |
parent | 1181cbbfd7c913c51d9836272ad30cfe851c4699 (diff) | |
download | frameworks_base-ba22d21c3a8efc05a0505c4a32c2cf6e1b94dd62.zip frameworks_base-ba22d21c3a8efc05a0505c4a32c2cf6e1b94dd62.tar.gz frameworks_base-ba22d21c3a8efc05a0505c4a32c2cf6e1b94dd62.tar.bz2 |
Merge "Fast no-op path for StrictMode.Span on user builds."
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/StrictMode.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index 8762512..97f015b 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -106,6 +106,8 @@ public final class StrictMode { private static final String TAG = "StrictMode"; private static final boolean LOG_V = false; + private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE); + // Only log a duplicate stack trace to the logs every second. private static final long MIN_LOG_INTERVAL_MS = 1000; @@ -693,7 +695,7 @@ public final class StrictMode { public static boolean conditionallyEnableDebugLogging() { // For debug builds, log event loop stalls to dropbox for analysis. // Similar logic also appears in ActivityThread.java for system apps. - if ("user".equals(Build.TYPE)) { + if (IS_USER_BUILD) { setCloseGuardEnabled(false); return false; } @@ -1240,6 +1242,11 @@ public final class StrictMode { mContainerState = threadState; } + // Empty constructor for the NO_OP_SPAN + protected Span() { + mContainerState = null; + } + /** * To be called when the critical span is complete (i.e. the * animation is done animating). This can be called on any @@ -1286,6 +1293,13 @@ public final class StrictMode { } } + // The no-op span that's used in user builds. + private static final Span NO_OP_SPAN = new Span() { + public void finish() { + // Do nothing. + } + }; + /** * Linked lists of active spans and a freelist. * @@ -1327,6 +1341,9 @@ public final class StrictMode { * @hide */ public static Span enterCriticalSpan(String name) { + if (IS_USER_BUILD) { + return NO_OP_SPAN; + } if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name must be non-null and non-empty"); } |