summaryrefslogtreecommitdiffstats
path: root/provider_src/com/android/email/DebugUtils.java
blob: 94ce78e75d599fc2965b3e5834780b5ddef42b15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.android.email;

import android.content.Context;

import com.android.email.service.EmailServiceUtils;
import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.utility.Utility;
import com.android.mail.utils.LogTag;

public class DebugUtils {
    public static final String LOG_TAG = LogTag.getLogTag();

    public static boolean DEBUG;
    public static boolean DEBUG_EXCHANGE;
    public static boolean DEBUG_FILE;

    public static void init(final Context context) {
        final Preferences prefs = Preferences.getPreferences(context);
        DEBUG = prefs.getEnableDebugLogging();
        DEBUG_EXCHANGE = prefs.getEnableExchangeLogging();
        DEBUG_FILE = prefs.getEnableExchangeFileLogging();

        // Enable logging in the EAS service, so it starts up as early as possible.
        updateLoggingFlags(context);
        enableStrictMode(prefs.getEnableStrictMode());
    }

    /**
     * Load enabled debug flags from the preferences and update the EAS debug flag.
     */
    public static void updateLoggingFlags(Context context) {
        Preferences prefs = Preferences.getPreferences(context);
        int debugLogging = prefs.getEnableDebugLogging() ? EmailServiceProxy.DEBUG_BIT : 0;
        int exchangeLogging =
                prefs.getEnableExchangeLogging() ? EmailServiceProxy.DEBUG_EXCHANGE_BIT: 0;
        int fileLogging =
                prefs.getEnableExchangeFileLogging() ? EmailServiceProxy.DEBUG_FILE_BIT : 0;
        int enableStrictMode =
                prefs.getEnableStrictMode() ? EmailServiceProxy.DEBUG_ENABLE_STRICT_MODE : 0;
        int debugBits = debugLogging | exchangeLogging | fileLogging | enableStrictMode;
        EmailServiceUtils.setRemoteServicesLogging(context, debugBits);
    }

    public static void  enableStrictMode(final boolean enable) {
        Utility.enableStrictMode(enable);
    }

}