altosdroid: Disable debug output on release builds
authorKeith Packard <keithp@keithp.com>
Fri, 29 May 2015 05:06:55 +0000 (22:06 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 29 May 2015 05:06:55 +0000 (22:06 -0700)
We generate an awful lot of debug spew to the log; presumably that's
not helping performance, so lose that for release builds.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosdroid/src/org/altusmetrum/AltosDroid/AltosDebug.java
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java

index 80f1861b15ba6b7732ac14c2e0a8fe1de9940de6..cee6e56e2d00ba4a499d6f3f5d88af89d87b49e6 100644 (file)
@@ -32,12 +32,27 @@ import android.widget.*;
 import android.location.Location;
 import android.content.*;
 import android.util.Log;
 import android.location.Location;
 import android.content.*;
 import android.util.Log;
-import android.os.Looper;
+import android.os.*;
+import android.content.pm.*;
 
 public class AltosDebug {
        // Debugging
        static final String TAG = "AltosDroid";
 
 public class AltosDebug {
        // Debugging
        static final String TAG = "AltosDroid";
-       public static final boolean D = true;
+
+       static boolean  D = true;
+
+       static void init(Context context) {
+               ApplicationInfo app_info = context.getApplicationInfo();
+
+               if ((app_info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
+                       Log.d(TAG, "Enable debugging\n");
+                       D = true;
+               } else {
+                       Log.d(TAG, "Disable debugging\n");
+                       D = false;
+               }
+       }
+
 
        static void info(String format, Object ... arguments) {
                Log.i(TAG, String.format(format, arguments));
 
        static void info(String format, Object ... arguments) {
                Log.i(TAG, String.format(format, arguments));
index 97373ab8da30e70b9890438022e7c5c9a1b501c1..6c6566ba63573f07bdd33122c602439c95a63441 100644 (file)
@@ -419,6 +419,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
+               AltosDebug.init(this);
                AltosDebug.debug("+++ ON CREATE +++");
 
                fm = getSupportFragmentManager();
                AltosDebug.debug("+++ ON CREATE +++");
 
                fm = getSupportFragmentManager();