From fc77bf6029094c471ba7d38c27b03bf13606c58d Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 9 Jun 2013 02:36:12 +0200 Subject: [PATCH] Only enable debug logging when running a debuggable build There have been some complaints from Android developers that get flooded by K-9's log messages when debugging their own apps. Oops :) --- src/com/fsck/k9/K9.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index baaa6c1ad..6249a12ec 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -16,6 +16,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; @@ -179,6 +180,10 @@ public class K9 extends Application { */ private static SharedPreferences sDatabaseVersionCache; + /** + * {@code true} if this is a debuggable build. + */ + private static boolean sIsDebuggable; private static boolean mAnimations = true; @@ -543,6 +548,8 @@ public class K9 extends Application { galleryBuggy = checkForBuggyGallery(); + sIsDebuggable = ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0); + checkCachedDatabaseVersion(); Preferences prefs = Preferences.getPreferences(this); @@ -667,7 +674,7 @@ public class K9 extends Application { public static void loadPrefs(Preferences prefs) { SharedPreferences sprefs = prefs.getPreferences(); DEBUG = sprefs.getBoolean("enableDebugLogging", false); - if (!DEBUG && Debug.isDebuggerConnected()) { + if (!DEBUG && sIsDebuggable && Debug.isDebuggerConnected()) { // If the debugger is attached, we're probably (surprise surprise) debugging something. DEBUG = true; Log.i(K9.LOG_TAG, "Debugger attached; enabling debug logging.");