11

I'm anxiously awaiting the open source release of StrictMode for continuation of our platform development. The sample in the Android blog entry suggests surrounding the StrictMode calls with

if (DEVELOPER_MODE) {
    ...
}

For SDK development, I'd expect this constant to be locally defined by each application. However, for platform development, is android.util.Config.DEBUG the best way to determine whether to turn this on?

avalancha
  • 1,148
  • 1
  • 19
  • 38
Dave Boldt
  • 111
  • 1
  • 3

4 Answers4

16

Sorry, DEVELOPER_MODE was just an arbitrary name I picked for the blog post and Javadoc. Perhaps I should make that more clear in the docs.

I'd imagined people would make their own hard-coded,

private static final boolean DEVELOPER_MODE = false;

... that they maintain by hand, but looks like Config.DEBUG would have been a better thing to use. I didn't even know about that! :)

Brad Fitzpatrick
  • 3,461
  • 1
  • 17
  • 9
  • I notice in the OpenSource Gingerbread code that none of the Core Android Apps are using StrictMode. I was hoping to see how they were using it to model how our own platform development would use StrictMode. Can you provide any insights into how Android's platform development team is enabling/disabling StrictMode during their development cycle. – Dave Boldt Jan 05 '11 at 19:26
  • Dave, that's because they're ALL using StrictMode. We turn it on for all system apps: – Brad Fitzpatrick Jan 18 '11 at 23:06
  • Whoops, only single line comments (I hit Enter too early). See http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/app/ActivityThread.java;h=78df78009ab9735393672a81a9b2960245cfc980;hb=refs/heads/master and search for "conditionallyEnableDebugLogging", which is public but a hidden API. – Brad Fitzpatrick Jan 18 '11 at 23:07
  • @BradFitzpatrick Damn as soon as I opened your blog entry I had to search if DEVELOPER_MODE existed and I found this question. For a moment there I setted my expectation for android from low to normal but now are returned to low. – Fabio Marcolini Mar 25 '14 at 09:08
4

Config.DEBUG is not going to actually works since it is pretty much always set to false. It is better to look at the debuggable attribute in the AndroidManifest file . I have documented it on a blog post. Links are with this answer

Community
  • 1
  • 1
Manfred Moser
  • 28,342
  • 13
  • 87
  • 120
1

It's an old question, but I'd like to mention that the closest alternative I can imagine is BuildConfig.DEBUG for application engineers. It returns whether this is a debug build.

Teng-pao Yu
  • 931
  • 10
  • 24
1

To Answer my own question... As a platform developer (one using Android to create a device), the Activity Manager in Android automatically enables StrictMode on the main thread for all apps installed on the System Partition whenever the platform is built with an eng or userdebug built. I agree with Manfred that Config.DEBUG is not appropriate for SDK developers. Essentially, platform developers writing applications which are loaded by default on the System Partition don't have to do anything to take advantage of StrictMode - the platform does it for them.

Dave Boldt
  • 11
  • 1
  • I did not get exactly what do we have as app developers (i.e. not platform developers). Should we go with the hidden `conditionallyEnableDebugLogging`? Check the AndroidManifest file? Or...? TA – superjos Nov 06 '12 at 12:15