Definition of DEVELOPER_MODE for StrictMode
Asked Answered
L

4

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?

Loaning answered 15/12, 2010 at 15:0 Comment(1)
I assumed it was a boolean they defined just an arbitrary name.Pamper
J
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! :)

Jeter answered 18/12, 2010 at 3:21 Comment(4)
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.Loaning
Dave, that's because they're ALL using StrictMode. We turn it on for all system apps:Jeter
Whoops, only single line comments (I hit Enter too early). See android.git.kernel.org/?p=platform/frameworks/… and search for "conditionallyEnableDebugLogging", which is public but a hidden API.Jeter
@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.Mcdowell
L
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

Lutanist answered 7/1, 2011 at 16:18 Comment(0)
L
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.

Loaning answered 13/1, 2011 at 14:9 Comment(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...? TAScalar
C
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.

Cornish answered 10/8, 2017 at 6:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.