From c49a856046a056d843923bca13ecb33c45151beb Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 24 Dec 2010 18:55:01 +0000 Subject: [PATCH] Enable Strict Mode when a new "developer mode" is enabled and we're running on 2.3 or newer --- src/com/fsck/k9/K9.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index 51476f460..a92bec54e 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -88,6 +88,14 @@ public class K9 extends Application public static final String logFile = null; //public static final String logFile = Environment.getExternalStorageDirectory() + "/k9mail/debug.log"; + /** + * If this is enabled, various development settings will be enabled + * It should NEVER be on for Market builds + * Right now, it just governs strictmode + **/ + public static boolean DEVELOPER_MODE = true; + + /** * If this is enabled there will be additional logging information sent to * Log.d, including protocol dumps. @@ -456,9 +464,11 @@ public class K9 extends Application @Override public void onCreate() { + maybeSetupStrictMode(); super.onCreate(); app = this; + galleryBuggy = checkForBuggyGallery(); Preferences prefs = Preferences.getPreferences(this); @@ -591,6 +601,27 @@ public class K9 extends Application notifyObservers(); } + private void maybeSetupStrictMode() + { + if (!K9.DEVELOPER_MODE) + return; + + try + { + Class strictMode = Class.forName("android.os.StrictMode"); + Method enableDefaults = strictMode.getMethod("enableDefaults"); + enableDefaults.invoke(strictMode); + } + + catch (Exception e) + { + // Discard , as it means we're not running on a device with strict mode + Log.v(K9.LOG_TAG, "Failed to turn on strict mode "+e); + } + + } + + /** * since Android invokes Application.onCreate() only after invoking all * other components' onCreate(), here is a way to notify interested