diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2010-11-24 15:27:51 -0800 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@android.com> | 2010-11-24 15:27:51 -0800 |
commit | f54545927f365d6e55cbf66ff9f7ffe91aada774 (patch) | |
tree | 830fec91bfb6aaae4b03e50dfc679a45e6832911 /core/java/android/os/StrictMode.java | |
parent | ed798a0dd62fc267d941fb592dfc99e6ae968324 (diff) | |
download | frameworks_base-f54545927f365d6e55cbf66ff9f7ffe91aada774.zip frameworks_base-f54545927f365d6e55cbf66ff9f7ffe91aada774.tar.gz frameworks_base-f54545927f365d6e55cbf66ff9f7ffe91aada774.tar.bz2 |
Don't flash StrictMode from the system server.
These are false positives from a developer's point of view.
Change-Id: Ic8baf81c0e2cf559a38c1fe6adfa6e739dd3eaed
Diffstat (limited to 'core/java/android/os/StrictMode.java')
-rw-r--r-- | core/java/android/os/StrictMode.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index c2ecf13..754d073 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -719,13 +719,37 @@ public final class StrictMode { return new ThreadPolicy(oldPolicyMask); } + // We don't want to flash the screen red in the system server + // process, nor do we want to modify all the call sites of + // conditionallyEnableDebugLogging() in the system server, + // so instead we use this to determine if we are the system server. + private static boolean amTheSystemServerProcess() { + // Fast path. Most apps don't have the system server's UID. + if (Process.myUid() != Process.SYSTEM_UID) { + return false; + } + + // The settings app, though, has the system server's UID so + // look up our stack to see if we came from the system server. + Throwable stack = new Throwable(); + stack.fillInStackTrace(); + for (StackTraceElement ste : stack.getStackTrace()) { + String clsName = ste.getClassName(); + if (clsName != null && clsName.startsWith("com.android.server.")) { + return true; + } + } + return false; + } + /** * Enable DropBox logging for debug phone builds. * * @hide */ public static boolean conditionallyEnableDebugLogging() { - boolean doFlashes = SystemProperties.getBoolean(VISUAL_PROPERTY, IS_ENG_BUILD); + boolean doFlashes = !amTheSystemServerProcess() && + SystemProperties.getBoolean(VISUAL_PROPERTY, IS_ENG_BUILD); // For debug builds, log event loop stalls to dropbox for analysis. // Similar logic also appears in ActivityThread.java for system apps. |