From 8ee17c7012105fd7a5bad644b455d3e894b557dc Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Fri, 29 Jan 2010 15:44:56 -0800 Subject: [PATCH] Unifying dupe code in Debug.java and Email.java. --- src/com/android/email/Email.java | 7 ++----- src/com/android/email/activity/Debug.java | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java index 2807e50db..ee928a76d 100644 --- a/src/com/android/email/Email.java +++ b/src/com/android/email/Email.java @@ -17,6 +17,7 @@ package com.android.email; import com.android.email.activity.AccountShortcutPicker; +import com.android.email.activity.Debug; import com.android.email.activity.MessageCompose; import com.android.email.mail.internet.BinaryTempFileBody; import com.android.email.provider.EmailContent; @@ -222,11 +223,7 @@ public class Email extends Application { BinaryTempFileBody.setTempDirectory(getCacheDir()); // Enable logging in the EAS service, so it starts up as early as possible. - int debugLogging = prefs.getEnableDebugLogging() ? Eas.DEBUG_BIT : 0; - int exchangeLogging = prefs.getEnableExchangeLogging() ? Eas.DEBUG_EXCHANGE_BIT : 0; - int fileLogging = prefs.getEnableExchangeFileLogging() ? Eas.DEBUG_FILE_BIT : 0; - int debugBits = debugLogging + exchangeLogging + fileLogging; - Controller.getInstance(this).serviceLogging(debugBits); + Debug.updateLoggingFlags(this); } /** diff --git a/src/com/android/email/activity/Debug.java b/src/com/android/email/activity/Debug.java index be3c934a9..4526f0d0a 100644 --- a/src/com/android/email/activity/Debug.java +++ b/src/com/android/email/activity/Debug.java @@ -24,6 +24,7 @@ import com.android.exchange.Eas; import com.android.exchange.utility.FileLogger; import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -90,13 +91,7 @@ public class Debug extends Activity implements OnCheckedChangeListener { break; } - // Now rebuild "debug bits" and send to EAS service - int debugLogging = mPreferences.getEnableDebugLogging() ? Eas.DEBUG_BIT : 0; - int exchangeLogging = mPreferences.getEnableExchangeLogging() ? Eas.DEBUG_EXCHANGE_BIT : 0; - int fileLogging = mPreferences.getEnableExchangeFileLogging() ? Eas.DEBUG_FILE_BIT : 0; - int debugBits = debugLogging | exchangeLogging | fileLogging; - - Controller.getInstance(getApplication()).serviceLogging(debugBits); + updateLoggingFlags(this); } @Override @@ -116,4 +111,15 @@ public class Debug extends Activity implements OnCheckedChangeListener { return true; } + /** + * Load enabled debug flags from the preferences and upadte the EAS debug flag. + */ + public static void updateLoggingFlags(Context context) { + Preferences prefs = Preferences.getPreferences(context); + int debugLogging = prefs.getEnableDebugLogging() ? Eas.DEBUG_BIT : 0; + int exchangeLogging = prefs.getEnableExchangeLogging() ? Eas.DEBUG_EXCHANGE_BIT : 0; + int fileLogging = prefs.getEnableExchangeFileLogging() ? Eas.DEBUG_FILE_BIT : 0; + int debugBits = debugLogging | exchangeLogging | fileLogging; + Controller.getInstance(context).serviceLogging(debugBits); + } }