Home | History | Annotate | Download | only in email
      1 package com.android.email;
      2 
      3 import android.content.Context;
      4 
      5 import com.android.email.service.EmailServiceUtils;
      6 import com.android.emailcommon.service.EmailServiceProxy;
      7 import com.android.emailcommon.utility.Utility;
      8 import com.android.mail.utils.LogTag;
      9 
     10 public class DebugUtils {
     11     public static final String LOG_TAG = LogTag.getLogTag();
     12 
     13     public static boolean DEBUG;
     14     public static boolean DEBUG_EXCHANGE;
     15     public static boolean DEBUG_FILE;
     16 
     17     public static void init(final Context context) {
     18         final Preferences prefs = Preferences.getPreferences(context);
     19         DEBUG = prefs.getEnableDebugLogging();
     20         DEBUG_EXCHANGE = prefs.getEnableExchangeLogging();
     21         DEBUG_FILE = prefs.getEnableExchangeFileLogging();
     22 
     23         // Enable logging in the EAS service, so it starts up as early as possible.
     24         updateLoggingFlags(context);
     25         enableStrictMode(prefs.getEnableStrictMode());
     26     }
     27 
     28     /**
     29      * Load enabled debug flags from the preferences and update the EAS debug flag.
     30      */
     31     public static void updateLoggingFlags(Context context) {
     32         Preferences prefs = Preferences.getPreferences(context);
     33         int debugLogging = prefs.getEnableDebugLogging() ? EmailServiceProxy.DEBUG_BIT : 0;
     34         int exchangeLogging =
     35                 prefs.getEnableExchangeLogging() ? EmailServiceProxy.DEBUG_EXCHANGE_BIT: 0;
     36         int fileLogging =
     37                 prefs.getEnableExchangeFileLogging() ? EmailServiceProxy.DEBUG_FILE_BIT : 0;
     38         int enableStrictMode =
     39                 prefs.getEnableStrictMode() ? EmailServiceProxy.DEBUG_ENABLE_STRICT_MODE : 0;
     40         int debugBits = debugLogging | exchangeLogging | fileLogging | enableStrictMode;
     41         EmailServiceUtils.setRemoteServicesLogging(context, debugBits);
     42     }
     43 
     44     public static void  enableStrictMode(final boolean enable) {
     45         Utility.enableStrictMode(enable);
     46     }
     47 
     48 }
     49