am 33ab7b34: am 30d8d696: am 51c65364: Put debug screen back into settings

* commit '33ab7b34533244770fa664ef9478587668634cb2':
  Put debug screen back into settings
This commit is contained in:
Martin Hibdon 2014-11-02 17:37:01 +00:00 committed by Android Git Automerger
commit 341c8ef2ec
22 changed files with 163 additions and 161 deletions

View File

@ -65,13 +65,13 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
private final boolean isRemote; private final boolean isRemote;
// Standard debugging // Standard debugging
public static final int DEBUG_BIT = 1; public static final int DEBUG_BIT = 0x01;
// Verbose (parser) logging // Verbose (parser) logging
public static final int DEBUG_VERBOSE_BIT = 2; public static final int DEBUG_EXCHANGE_BIT = 0x02;
// File (SD card) logging // File (SD card) logging
public static final int DEBUG_FILE_BIT = 4; public static final int DEBUG_FILE_BIT = 0x04;
// Enable strict mode // Enable strict mode
public static final int DEBUG_ENABLE_STRICT_MODE = 8; public static final int DEBUG_ENABLE_STRICT_MODE = 0x08;
// The first two constructors are used with local services that can be referenced by class // The first two constructors are used with local services that can be referenced by class
public EmailServiceProxy(Context _context, Class<?> _class) { public EmailServiceProxy(Context _context, Class<?> _class) {

View File

@ -26,7 +26,7 @@
android:text="@string/debug_enable_debug_logging_label" android:text="@string/debug_enable_debug_logging_label"
/> />
<CheckBox <CheckBox
android:id="@+id/verbose_logging" android:id="@+id/exchange_logging"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/debug_enable_verbose_logging_label" android:text="@string/debug_enable_verbose_logging_label"

View File

@ -31,8 +31,6 @@
<!-- Name of application on Home screen --> <!-- Name of application on Home screen -->
<string name="app_name">Email</string> <string name="app_name">Email</string>
<!-- Title of debug screen -->
<string name="debug_title">Debug</string>
<!-- Actions will be used as buttons and in menu items --> <!-- Actions will be used as buttons and in menu items -->
<skip /> <skip />
@ -83,12 +81,14 @@
<!-- In the UI, the unread will be displayed with this name [CHAR LIMIT=15] --> <!-- In the UI, the unread will be displayed with this name [CHAR LIMIT=15] -->
<string name="mailbox_name_display_unread">Unread</string> <string name="mailbox_name_display_unread">Unread</string>
<!-- Title of debug screen -->
<string name="debug_title">Debug</string>
<!-- Do Not Translate. Checkbox label, shown only on debug screen --> <!-- Do Not Translate. Checkbox label, shown only on debug screen -->
<string name="debug_enable_debug_logging_label" translatable="false"> <string name="debug_enable_debug_logging_label" translatable="false">
Enable extra debug logging?</string> Enable extra debug logging?</string>
<!-- Do Not Translate. Checkbox label, shown only on debug screen --> <!-- Do Not Translate. Checkbox label, shown only on debug screen -->
<string name="debug_enable_verbose_logging_label" translatable="false"> <string name="debug_enable_verbose_logging_label" translatable="false">
Enable extremely verbose logging?</string> Enable exchange logging?</string>
<!-- Do Not Translate. Checkbox label, shown only on debug screen --> <!-- Do Not Translate. Checkbox label, shown only on debug screen -->
<string name="debug_enable_file_logging_label" translatable="false"> <string name="debug_enable_file_logging_label" translatable="false">
Enable sd card logging?</string> Enable sd card logging?</string>

View File

@ -0,0 +1,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);
}
}

View File

@ -28,7 +28,6 @@ import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.PowerManager.WakeLock; import android.os.PowerManager.WakeLock;
import com.android.email2.ui.MailActivityEmail;
import com.android.mail.utils.LogUtils; import com.android.mail.utils.LogUtils;
/** /**
@ -181,14 +180,14 @@ public class EmailConnectivityManager extends BroadcastReceiver {
if (info != null) { if (info != null) {
// We're done if there's an active network // We're done if there's an active network
if (waiting) { if (waiting) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, mName + ": Connectivity wait ended"); LogUtils.d(TAG, mName + ": Connectivity wait ended");
} }
} }
return; return;
} else { } else {
if (!waiting) { if (!waiting) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, mName + ": Connectivity waiting..."); LogUtils.d(TAG, mName + ": Connectivity waiting...");
} }
waiting = true; waiting = true;

View File

@ -36,7 +36,6 @@ import com.android.email.provider.AccountReconciler;
import com.android.email.provider.EmailProvider; import com.android.email.provider.EmailProvider;
import com.android.email.service.EmailBroadcastProcessorService; import com.android.email.service.EmailBroadcastProcessorService;
import com.android.email.service.EmailServiceUtils; import com.android.email.service.EmailServiceUtils;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent; import com.android.emailcommon.provider.EmailContent;
@ -140,7 +139,7 @@ public class SecurityPolicy {
try { try {
while (c.moveToNext()) { while (c.moveToNext()) {
policy.restore(c); policy.restore(c);
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Aggregate from: " + policy); LogUtils.d(TAG, "Aggregate from: " + policy);
} }
aggregate.mPasswordMinLength = aggregate.mPasswordMinLength =
@ -185,12 +184,12 @@ public class SecurityPolicy {
aggregate.mPasswordExpirationDays = 0; aggregate.mPasswordExpirationDays = 0;
if (aggregate.mPasswordComplexChars == Integer.MIN_VALUE) if (aggregate.mPasswordComplexChars == Integer.MIN_VALUE)
aggregate.mPasswordComplexChars = 0; aggregate.mPasswordComplexChars = 0;
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Calculated Aggregate: " + aggregate); LogUtils.d(TAG, "Calculated Aggregate: " + aggregate);
} }
return aggregate; return aggregate;
} }
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Calculated Aggregate: no policy"); LogUtils.d(TAG, "Calculated Aggregate: no policy");
} }
return Policy.NO_POLICY; return Policy.NO_POLICY;
@ -232,7 +231,7 @@ public class SecurityPolicy {
* rollbacks. * rollbacks.
*/ */
public void reducePolicies() { public void reducePolicies() {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "reducePolicies"); LogUtils.d(TAG, "reducePolicies");
} }
policiesUpdated(); policiesUpdated();
@ -247,7 +246,7 @@ public class SecurityPolicy {
*/ */
public boolean isActive(Policy policy) { public boolean isActive(Policy policy) {
int reasons = getInactiveReasons(policy); int reasons = getInactiveReasons(policy);
if (MailActivityEmail.DEBUG && (reasons != 0)) { if (DebugUtils.DEBUG && (reasons != 0)) {
StringBuilder sb = new StringBuilder("isActive for " + policy + ": "); StringBuilder sb = new StringBuilder("isActive for " + policy + ": ");
sb.append("FALSE -> "); sb.append("FALSE -> ");
if ((reasons & INACTIVE_NEED_ACTIVATION) != 0) { if ((reasons & INACTIVE_NEED_ACTIVATION) != 0) {
@ -407,12 +406,12 @@ public class SecurityPolicy {
Policy aggregatePolicy = getAggregatePolicy(); Policy aggregatePolicy = getAggregatePolicy();
// if empty set, detach from policy manager // if empty set, detach from policy manager
if (aggregatePolicy == Policy.NO_POLICY) { if (aggregatePolicy == Policy.NO_POLICY) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "setActivePolicies: none, remove admin"); LogUtils.d(TAG, "setActivePolicies: none, remove admin");
} }
dpm.removeActiveAdmin(mAdminName); dpm.removeActiveAdmin(mAdminName);
} else if (isActiveAdmin()) { } else if (isActiveAdmin()) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "setActivePolicies: " + aggregatePolicy); LogUtils.d(TAG, "setActivePolicies: " + aggregatePolicy);
} }
// set each policy in the policy manager // set each policy in the policy manager
@ -492,7 +491,7 @@ public class SecurityPolicy {
if (account.mPolicyKey == 0) return; if (account.mPolicyKey == 0) return;
Policy policy = Policy.restorePolicyWithId(mContext, account.mPolicyKey); Policy policy = Policy.restorePolicyWithId(mContext, account.mPolicyKey);
if (policy == null) return; if (policy == null) return;
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "policiesRequired for " + account.mDisplayName + ": " + policy); LogUtils.d(TAG, "policiesRequired for " + account.mDisplayName + ": " + policy);
} }

View File

@ -32,9 +32,9 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import com.android.email.DebugUtils;
import com.android.email.R; import com.android.email.R;
import com.android.email.SecurityPolicy; import com.android.email.SecurityPolicy;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.HostAuth; import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.provider.Policy; import com.android.emailcommon.provider.Policy;
@ -292,7 +292,7 @@ public class AccountSecurity extends Activity {
PasswordExpirationDialog dialog = PasswordExpirationDialog dialog =
PasswordExpirationDialog.newInstance(mAccount.getDisplayName(), PasswordExpirationDialog.newInstance(mAccount.getDisplayName(),
passwordExpired); passwordExpired);
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Showing password expiration dialog"); LogUtils.d(TAG, "Showing password expiration dialog");
} }
dialog.show(fm, "password_expiration"); dialog.show(fm, "password_expiration");
@ -308,7 +308,7 @@ public class AccountSecurity extends Activity {
if (fm.findFragmentByTag("security_needed") == null) { if (fm.findFragmentByTag("security_needed") == null) {
SecurityNeededDialog dialog = SecurityNeededDialog dialog =
SecurityNeededDialog.newInstance(mAccount.getDisplayName()); SecurityNeededDialog.newInstance(mAccount.getDisplayName());
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Showing security needed dialog"); LogUtils.d(TAG, "Showing security needed dialog");
} }
dialog.show(fm, "security_needed"); dialog.show(fm, "security_needed");
@ -349,7 +349,7 @@ public class AccountSecurity extends Activity {
// Step 1. Check if we are an active device administrator, and stop here to activate // Step 1. Check if we are an active device administrator, and stop here to activate
if (!security.isActiveAdmin()) { if (!security.isActiveAdmin()) {
if (mTriedAddAdministrator) { if (mTriedAddAdministrator) {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Not active admin: repost notification"); LogUtils.d(TAG, "Not active admin: repost notification");
} }
repostNotification(account, security); repostNotification(account, security);
@ -359,13 +359,13 @@ public class AccountSecurity extends Activity {
// retrieve name of server for the format string // retrieve name of server for the format string
final HostAuth hostAuth = account.mHostAuthRecv; final HostAuth hostAuth = account.mHostAuthRecv;
if (hostAuth == null) { if (hostAuth == null) {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "No HostAuth: repost notification"); LogUtils.d(TAG, "No HostAuth: repost notification");
} }
repostNotification(account, security); repostNotification(account, security);
finish(); finish();
} else { } else {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Not active admin: post initial notification"); LogUtils.d(TAG, "Not active admin: post initial notification");
} }
// try to become active - must happen here in activity, to get result // try to become active - must happen here in activity, to get result
@ -384,7 +384,7 @@ public class AccountSecurity extends Activity {
// Step 2. Check if the current aggregate security policy is being satisfied by the // Step 2. Check if the current aggregate security policy is being satisfied by the
// DevicePolicyManager (the current system security level). // DevicePolicyManager (the current system security level).
if (security.isActive(null)) { if (security.isActive(null)) {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Security active; clear holds"); LogUtils.d(TAG, "Security active; clear holds");
} }
Account.clearSecurityHoldOnAllAccounts(this); Account.clearSecurityHoldOnAllAccounts(this);
@ -404,13 +404,13 @@ public class AccountSecurity extends Activity {
// Step 5. If password is needed, try to have the user set it // Step 5. If password is needed, try to have the user set it
if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_PASSWORD) != 0) { if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_PASSWORD) != 0) {
if (mTriedSetPassword) { if (mTriedSetPassword) {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Password needed; repost notification"); LogUtils.d(TAG, "Password needed; repost notification");
} }
repostNotification(account, security); repostNotification(account, security);
finish(); finish();
} else { } else {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Password needed; request it via DPM"); LogUtils.d(TAG, "Password needed; request it via DPM");
} }
mTriedSetPassword = true; mTriedSetPassword = true;
@ -424,13 +424,13 @@ public class AccountSecurity extends Activity {
// Step 6. If encryption is needed, try to have the user set it // Step 6. If encryption is needed, try to have the user set it
if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_ENCRYPTION) != 0) { if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_ENCRYPTION) != 0) {
if (mTriedSetEncryption) { if (mTriedSetEncryption) {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Encryption needed; repost notification"); LogUtils.d(TAG, "Encryption needed; repost notification");
} }
repostNotification(account, security); repostNotification(account, security);
finish(); finish();
} else { } else {
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Encryption needed; request it via DPM"); LogUtils.d(TAG, "Encryption needed; request it via DPM");
} }
mTriedSetEncryption = true; mTriedSetEncryption = true;
@ -442,7 +442,7 @@ public class AccountSecurity extends Activity {
} }
// Step 7. No problems were found, so clear holds and exit // Step 7. No problems were found, so clear holds and exit
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Policies enforced; clear holds"); LogUtils.d(TAG, "Policies enforced; clear holds");
} }
Account.clearSecurityHoldOnAllAccounts(this); Account.clearSecurityHoldOnAllAccounts(this);
@ -501,7 +501,7 @@ public class AccountSecurity extends Activity {
b.setMessage(res.getString(R.string.account_security_dialog_content_fmt, accountName)); b.setMessage(res.getString(R.string.account_security_dialog_content_fmt, accountName));
b.setPositiveButton(android.R.string.ok, this); b.setPositiveButton(android.R.string.ok, this);
b.setNegativeButton(android.R.string.cancel, this); b.setNegativeButton(android.R.string.cancel, this);
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Posting security needed dialog"); LogUtils.d(TAG, "Posting security needed dialog");
} }
return b.create(); return b.create();
@ -518,13 +518,13 @@ public class AccountSecurity extends Activity {
} }
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "User accepts; advance to next step"); LogUtils.d(TAG, "User accepts; advance to next step");
} }
activity.tryAdvanceSecurity(activity.mAccount); activity.tryAdvanceSecurity(activity.mAccount);
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
if (MailActivityEmail.DEBUG || DEBUG) { if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "User declines; repost notification"); LogUtils.d(TAG, "User declines; repost notification");
} }
AccountSecurity.repostNotification( AccountSecurity.repostNotification(

View File

@ -27,11 +27,11 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import com.android.email.DebugUtils;
import com.android.email.Preferences; import com.android.email.Preferences;
import com.android.email.R; import com.android.email.R;
import com.android.email.activity.UiUtilities; import com.android.email.activity.UiUtilities;
import com.android.email.service.EmailServiceUtils; import com.android.email.service.EmailServiceUtils;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.mail.utils.LogUtils; import com.android.mail.utils.LogUtils;
@ -45,8 +45,8 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
if (Logging.DEBUG_LIFECYCLE && MailActivityEmail.DEBUG) { if (Logging.DEBUG_LIFECYCLE && DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "AccountSetupBasicsFragment onCreateView"); LogUtils.d(Logging.LOG_TAG, "DebugFragment onCreateView");
} }
View view = inflater.inflate(R.layout.debug, container, false); View view = inflater.inflate(R.layout.debug, container, false);
@ -54,21 +54,21 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
mPreferences = Preferences.getPreferences(context); mPreferences = Preferences.getPreferences(context);
final CheckBox enableDebugLoggingView = UiUtilities.getView(view, R.id.debug_logging); final CheckBox enableDebugLoggingView = UiUtilities.getView(view, R.id.debug_logging);
enableDebugLoggingView.setChecked(MailActivityEmail.DEBUG); enableDebugLoggingView.setChecked(DebugUtils.DEBUG);
final CheckBox enableVerboseLoggingView = UiUtilities.getView(view, R.id.verbose_logging); final CheckBox enableExchangeLoggingView = UiUtilities.getView(view, R.id.exchange_logging);
final CheckBox enableFileLoggingView = UiUtilities.getView(view, R.id.file_logging); final CheckBox enableFileLoggingView = UiUtilities.getView(view, R.id.file_logging);
// Note: To prevent recursion while presetting checkboxes, assign all listeners last // Note: To prevent recursion while presetting checkboxes, assign all listeners last
enableDebugLoggingView.setOnCheckedChangeListener(this); enableDebugLoggingView.setOnCheckedChangeListener(this);
if (EmailServiceUtils.areRemoteServicesInstalled(context)) { if (EmailServiceUtils.areRemoteServicesInstalled(context)) {
enableVerboseLoggingView.setChecked(MailActivityEmail.DEBUG_VERBOSE); enableExchangeLoggingView.setChecked(DebugUtils.DEBUG_EXCHANGE);
enableFileLoggingView.setChecked(MailActivityEmail.DEBUG_FILE); enableFileLoggingView.setChecked(DebugUtils.DEBUG_FILE);
enableVerboseLoggingView.setOnCheckedChangeListener(this); enableExchangeLoggingView.setOnCheckedChangeListener(this);
enableFileLoggingView.setOnCheckedChangeListener(this); enableFileLoggingView.setOnCheckedChangeListener(this);
} else { } else {
enableVerboseLoggingView.setVisibility(View.GONE); enableExchangeLoggingView.setVisibility(View.GONE);
enableFileLoggingView.setVisibility(View.GONE); enableFileLoggingView.setVisibility(View.GONE);
} }
@ -87,24 +87,23 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
switch (buttonView.getId()) { switch (buttonView.getId()) {
case R.id.debug_logging: case R.id.debug_logging:
mPreferences.setEnableDebugLogging(isChecked); mPreferences.setEnableDebugLogging(isChecked);
MailActivityEmail.DEBUG = isChecked; DebugUtils.DEBUG = isChecked;
MailActivityEmail.DEBUG_EXCHANGE = isChecked;
break; break;
case R.id.verbose_logging: case R.id.exchange_logging:
mPreferences.setEnableExchangeLogging(isChecked); mPreferences.setEnableExchangeLogging(isChecked);
MailActivityEmail.DEBUG_VERBOSE = isChecked; DebugUtils.DEBUG_EXCHANGE = isChecked;
break; break;
case R.id.file_logging: case R.id.file_logging:
mPreferences.setEnableExchangeFileLogging(isChecked); mPreferences.setEnableExchangeFileLogging(isChecked);
MailActivityEmail.DEBUG_FILE = isChecked; DebugUtils.DEBUG_FILE = isChecked;
break; break;
case R.id.debug_enable_strict_mode: case R.id.debug_enable_strict_mode:
mPreferences.setEnableStrictMode(isChecked); mPreferences.setEnableStrictMode(isChecked);
MailActivityEmail.enableStrictMode(isChecked); DebugUtils.enableStrictMode(isChecked);
break; break;
} }
MailActivityEmail.updateLoggingFlags(getActivity()); DebugUtils.updateLoggingFlags(getActivity());
} }
@Override @Override

View File

@ -19,6 +19,7 @@ package com.android.email.mail.store;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import com.android.email.DebugUtils;
import com.android.email.mail.internet.AuthenticationCache; import com.android.email.mail.internet.AuthenticationCache;
import com.android.email.mail.store.ImapStore.ImapException; import com.android.email.mail.store.ImapStore.ImapException;
import com.android.email.mail.store.imap.ImapConstants; import com.android.email.mail.store.imap.ImapConstants;
@ -28,7 +29,6 @@ import com.android.email.mail.store.imap.ImapResponseParser;
import com.android.email.mail.store.imap.ImapUtility; import com.android.email.mail.store.imap.ImapUtility;
import com.android.email.mail.transport.DiscourseLogger; import com.android.email.mail.transport.DiscourseLogger;
import com.android.email.mail.transport.MailTransport; import com.android.email.mail.transport.MailTransport;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.AuthenticationFailedException; import com.android.emailcommon.mail.AuthenticationFailedException;
import com.android.emailcommon.mail.CertificateValidationException; import com.android.emailcommon.mail.CertificateValidationException;
@ -179,7 +179,7 @@ class ImapConnection {
mImapStore.ensurePrefixIsValid(); mImapStore.ensurePrefixIsValid();
} catch (SSLException e) { } catch (SSLException e) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e, "SSLException"); LogUtils.d(Logging.LOG_TAG, e, "SSLException");
} }
throw new CertificateValidationException(e.getMessage(), e); throw new CertificateValidationException(e.getMessage(), e);
@ -187,7 +187,7 @@ class ImapConnection {
// NOTE: Unlike similar code in POP3, I'm going to rethrow as-is. There is a lot // NOTE: Unlike similar code in POP3, I'm going to rethrow as-is. There is a lot
// of other code here that catches IOException and I don't want to break it. // of other code here that catches IOException and I don't want to break it.
// This catch is only here to enhance logging of connection-time issues. // This catch is only here to enhance logging of connection-time issues.
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe, "IOException"); LogUtils.d(Logging.LOG_TAG, ioe, "IOException");
} }
throw ioe; throw ioe;
@ -442,7 +442,7 @@ class ImapConnection {
executeSimpleCommand(mIdPhrase); executeSimpleCommand(mIdPhrase);
} catch (ImapException ie) { } catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem. // Log for debugging, but this is not a fatal problem.
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException"); LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
} }
} catch (IOException ioe) { } catch (IOException ioe) {
@ -467,7 +467,7 @@ class ImapConnection {
responseList = executeSimpleCommand(ImapConstants.NAMESPACE); responseList = executeSimpleCommand(ImapConstants.NAMESPACE);
} catch (ImapException ie) { } catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem. // Log for debugging, but this is not a fatal problem.
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException"); LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
} }
} catch (IOException ioe) { } catch (IOException ioe) {
@ -501,7 +501,7 @@ class ImapConnection {
executeSimpleCommand(getLoginPhrase(), true); executeSimpleCommand(getLoginPhrase(), true);
} }
} catch (ImapException ie) { } catch (ImapException ie) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException"); LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
} }
@ -588,7 +588,7 @@ class ImapConnection {
responseList = executeSimpleCommand(ImapConstants.LIST + " \"\" \"\""); responseList = executeSimpleCommand(ImapConstants.LIST + " \"\" \"\"");
} catch (ImapException ie) { } catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem. // Log for debugging, but this is not a fatal problem.
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException"); LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
} }
} catch (IOException ioe) { } catch (IOException ioe) {
@ -620,7 +620,7 @@ class ImapConnection {
// Per RFC requirement (3501-6.2.1) gather new capabilities // Per RFC requirement (3501-6.2.1) gather new capabilities
return(queryCapabilities()); return(queryCapabilities());
} else { } else {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "TLS not supported but required"); LogUtils.d(Logging.LOG_TAG, "TLS not supported but required");
} }
throw new MessagingException(MessagingException.TLS_REQUIRED); throw new MessagingException(MessagingException.TLS_REQUIRED);

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64DataException; import android.util.Base64DataException;
import com.android.email.DebugUtils;
import com.android.email.mail.store.ImapStore.ImapException; import com.android.email.mail.store.ImapStore.ImapException;
import com.android.email.mail.store.ImapStore.ImapMessage; import com.android.email.mail.store.ImapStore.ImapMessage;
import com.android.email.mail.store.imap.ImapConstants; import com.android.email.mail.store.imap.ImapConstants;
@ -29,7 +30,6 @@ import com.android.email.mail.store.imap.ImapResponse;
import com.android.email.mail.store.imap.ImapString; import com.android.email.mail.store.imap.ImapString;
import com.android.email.mail.store.imap.ImapUtility; import com.android.email.mail.store.imap.ImapUtility;
import com.android.email.service.ImapService; import com.android.email.service.ImapService;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.BinaryTempFileBody; import com.android.emailcommon.internet.BinaryTempFileBody;
import com.android.emailcommon.internet.MimeBodyPart; import com.android.emailcommon.internet.MimeBodyPart;
@ -1265,7 +1265,7 @@ class ImapFolder extends Folder {
} }
private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) { private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "IO Exception detected: ", ioe); LogUtils.d(Logging.LOG_TAG, "IO Exception detected: ", ioe);
} }
connection.close(); connection.close();

View File

@ -19,9 +19,9 @@ package com.android.email.mail.store;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import com.android.email.DebugUtils;
import com.android.email.mail.Store; import com.android.email.mail.Store;
import com.android.email.mail.transport.MailTransport; import com.android.email.mail.transport.MailTransport;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.MimeMessage; import com.android.emailcommon.internet.MimeMessage;
import com.android.emailcommon.mail.AuthenticationFailedException; import com.android.emailcommon.mail.AuthenticationFailedException;
@ -212,7 +212,7 @@ public class Pop3Store extends Store {
executeSimpleCommand("STLS"); executeSimpleCommand("STLS");
mTransport.reopenTls(); mTransport.reopenTls();
} else { } else {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "TLS not supported but required"); LogUtils.d(Logging.LOG_TAG, "TLS not supported but required");
} }
throw new MessagingException(MessagingException.TLS_REQUIRED); throw new MessagingException(MessagingException.TLS_REQUIRED);
@ -223,14 +223,14 @@ public class Pop3Store extends Store {
executeSensitiveCommand("USER " + mUsername, "USER /redacted/"); executeSensitiveCommand("USER " + mUsername, "USER /redacted/");
executeSensitiveCommand("PASS " + mPassword, "PASS /redacted/"); executeSensitiveCommand("PASS " + mPassword, "PASS /redacted/");
} catch (MessagingException me) { } catch (MessagingException me) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, me.toString()); LogUtils.d(Logging.LOG_TAG, me.toString());
} }
throw new AuthenticationFailedException(null, me); throw new AuthenticationFailedException(null, me);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
mTransport.close(); mTransport.close();
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe.toString()); LogUtils.d(Logging.LOG_TAG, ioe.toString());
} }
throw new MessagingException(MessagingException.IOERROR, ioe.toString()); throw new MessagingException(MessagingException.IOERROR, ioe.toString());
@ -254,7 +254,7 @@ public class Pop3Store extends Store {
} }
if (statException != null) { if (statException != null) {
mTransport.close(); mTransport.close();
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, statException.toString()); LogUtils.d(Logging.LOG_TAG, statException.toString());
} }
throw new MessagingException("POP3 STAT", statException); throw new MessagingException("POP3 STAT", statException);
@ -325,7 +325,7 @@ public class Pop3Store extends Store {
indexMsgNums(1, mMessageCount); indexMsgNums(1, mMessageCount);
} catch (IOException ioe) { } catch (IOException ioe) {
mTransport.close(); mTransport.close();
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "Unable to index during getMessage " + ioe); LogUtils.d(Logging.LOG_TAG, "Unable to index during getMessage " + ioe);
} }
throw new MessagingException("getMessages", ioe); throw new MessagingException("getMessages", ioe);
@ -353,7 +353,7 @@ public class Pop3Store extends Store {
indexMsgNums(1, end); indexMsgNums(1, end);
} catch (IOException ioe) { } catch (IOException ioe) {
mTransport.close(); mTransport.close();
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe.toString()); LogUtils.d(Logging.LOG_TAG, ioe.toString());
} }
throw new MessagingException("getMessages", ioe); throw new MessagingException("getMessages", ioe);
@ -601,7 +601,7 @@ public class Pop3Store extends Store {
} }
} }
InputStream in = mTransport.getInputStream(); InputStream in = mTransport.getInputStream();
if (DEBUG_LOG_RAW_STREAM && MailActivityEmail.DEBUG) { if (DEBUG_LOG_RAW_STREAM && DebugUtils.DEBUG) {
in = new LoggingInputStream(in); in = new LoggingInputStream(in);
} }
message.parse(new Pop3ResponseInputStream(in), callback); message.parse(new Pop3ResponseInputStream(in), callback);
@ -668,7 +668,7 @@ public class Pop3Store extends Store {
} }
catch (IOException ioe) { catch (IOException ioe) {
mTransport.close(); mTransport.close();
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe.toString()); LogUtils.d(Logging.LOG_TAG, ioe.toString());
} }
throw new MessagingException("setFlags()", ioe); throw new MessagingException("setFlags()", ioe);

View File

@ -18,10 +18,10 @@ package com.android.email.mail.store.imap;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.email.DebugUtils;
import com.android.email.FixedLengthInputStream; import com.android.email.FixedLengthInputStream;
import com.android.email.PeekableInputStream; import com.android.email.PeekableInputStream;
import com.android.email.mail.transport.DiscourseLogger; import com.android.email.mail.transport.DiscourseLogger;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.MessagingException; import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.utility.LoggingInputStream; import com.android.emailcommon.utility.LoggingInputStream;
@ -89,7 +89,7 @@ public class ImapResponseParser {
*/ */
/* package for test */ ImapResponseParser(InputStream in, DiscourseLogger discourseLogger, /* package for test */ ImapResponseParser(InputStream in, DiscourseLogger discourseLogger,
int literalKeepInMemoryThreshold) { int literalKeepInMemoryThreshold) {
if (DEBUG_LOG_RAW_STREAM && MailActivityEmail.DEBUG) { if (DEBUG_LOG_RAW_STREAM && DebugUtils.DEBUG) {
in = new LoggingInputStream(in); in = new LoggingInputStream(in);
} }
mIn = new PeekableInputStream(in); mIn = new PeekableInputStream(in);
@ -99,7 +99,7 @@ public class ImapResponseParser {
private static IOException newEOSException() { private static IOException newEOSException() {
final String message = "End of stream reached"; final String message = "End of stream reached";
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, message); LogUtils.d(Logging.LOG_TAG, message);
} }
return new IOException(message); return new IOException(message);
@ -161,7 +161,7 @@ public class ImapResponseParser {
ImapResponse response = null; ImapResponse response = null;
try { try {
response = parseResponse(); response = parseResponse();
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "<<< " + response.toString()); LogUtils.d(Logging.LOG_TAG, "<<< " + response.toString());
} }

View File

@ -18,7 +18,7 @@ package com.android.email.mail.transport;
import android.content.Context; import android.content.Context;
import com.android.email2.ui.MailActivityEmail; import com.android.email.DebugUtils;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.CertificateValidationException; import com.android.emailcommon.mail.CertificateValidationException;
import com.android.emailcommon.mail.MessagingException; import com.android.emailcommon.mail.MessagingException;
@ -103,7 +103,7 @@ public class MailTransport {
* an SSL connection if indicated. * an SSL connection if indicated.
*/ */
public void open() throws MessagingException, CertificateValidationException { public void open() throws MessagingException, CertificateValidationException {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "*** " + mDebugLabel + " open " + LogUtils.d(Logging.LOG_TAG, "*** " + mDebugLabel + " open " +
getHost() + ":" + String.valueOf(getPort())); getHost() + ":" + String.valueOf(getPort()));
} }
@ -125,17 +125,17 @@ public class MailTransport {
mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512); mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512);
mSocket.setSoTimeout(SOCKET_READ_TIMEOUT); mSocket.setSoTimeout(SOCKET_READ_TIMEOUT);
} catch (SSLException e) { } catch (SSLException e) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e.toString()); LogUtils.d(Logging.LOG_TAG, e.toString());
} }
throw new CertificateValidationException(e.getMessage(), e); throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) { } catch (IOException ioe) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe.toString()); LogUtils.d(Logging.LOG_TAG, ioe.toString());
} }
throw new MessagingException(MessagingException.IOERROR, ioe.toString()); throw new MessagingException(MessagingException.IOERROR, ioe.toString());
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, iae.toString()); LogUtils.d(Logging.LOG_TAG, iae.toString());
} }
throw new MessagingException(MessagingException.UNSPECIFIED_EXCEPTION, iae.toString()); throw new MessagingException(MessagingException.UNSPECIFIED_EXCEPTION, iae.toString());
@ -159,12 +159,12 @@ public class MailTransport {
mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512); mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512);
} catch (SSLException e) { } catch (SSLException e) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e.toString()); LogUtils.d(Logging.LOG_TAG, e.toString());
} }
throw new CertificateValidationException(e.getMessage(), e); throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) { } catch (IOException ioe) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe.toString()); LogUtils.d(Logging.LOG_TAG, ioe.toString());
} }
throw new MessagingException(MessagingException.IOERROR, ioe.toString()); throw new MessagingException(MessagingException.IOERROR, ioe.toString());
@ -268,7 +268,7 @@ public class MailTransport {
* Writes a single line to the server using \r\n termination. * Writes a single line to the server using \r\n termination.
*/ */
public void writeLine(String s, String sensitiveReplacement) throws IOException { public void writeLine(String s, String sensitiveReplacement) throws IOException {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
if (sensitiveReplacement != null && !Logging.DEBUG_SENSITIVE) { if (sensitiveReplacement != null && !Logging.DEBUG_SENSITIVE) {
LogUtils.d(Logging.LOG_TAG, ">>> " + sensitiveReplacement); LogUtils.d(Logging.LOG_TAG, ">>> " + sensitiveReplacement);
} else { } else {
@ -300,11 +300,11 @@ public class MailTransport {
sb.append((char)d); sb.append((char)d);
} }
} }
if (d == -1 && MailActivityEmail.DEBUG) { if (d == -1 && DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "End of stream reached while trying to read line."); LogUtils.d(Logging.LOG_TAG, "End of stream reached while trying to read line.");
} }
String ret = sb.toString(); String ret = sb.toString();
if (loggable && MailActivityEmail.DEBUG) { if (loggable && DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "<<< " + ret); LogUtils.d(Logging.LOG_TAG, "<<< " + ret);
} }
return ret; return ret;

View File

@ -19,9 +19,9 @@ package com.android.email.mail.transport;
import android.content.Context; import android.content.Context;
import android.util.Base64; import android.util.Base64;
import com.android.email.DebugUtils;
import com.android.email.mail.Sender; import com.android.email.mail.Sender;
import com.android.email.mail.internet.AuthenticationCache; import com.android.email.mail.internet.AuthenticationCache;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.Rfc822Output; import com.android.emailcommon.internet.Rfc822Output;
import com.android.emailcommon.mail.Address; import com.android.emailcommon.mail.Address;
@ -128,7 +128,7 @@ public class SmtpSender extends Sender {
*/ */
result = executeSimpleCommand("EHLO " + localHost); result = executeSimpleCommand("EHLO " + localHost);
} else { } else {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "TLS not supported but required"); LogUtils.d(Logging.LOG_TAG, "TLS not supported but required");
} }
throw new MessagingException(MessagingException.TLS_REQUIRED); throw new MessagingException(MessagingException.TLS_REQUIRED);
@ -164,12 +164,12 @@ public class SmtpSender extends Sender {
// It is acceptable to hvae no authentication at all for SMTP. // It is acceptable to hvae no authentication at all for SMTP.
} }
} catch (SSLException e) { } catch (SSLException e) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e.toString()); LogUtils.d(Logging.LOG_TAG, e.toString());
} }
throw new CertificateValidationException(e.getMessage(), e); throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) { } catch (IOException ioe) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe.toString()); LogUtils.d(Logging.LOG_TAG, ioe.toString());
} }
throw new MessagingException(MessagingException.IOERROR, ioe.toString()); throw new MessagingException(MessagingException.IOERROR, ioe.toString());

View File

@ -25,7 +25,7 @@ import android.database.MatrixCursor;
import android.net.Uri; import android.net.Uri;
import android.util.LruCache; import android.util.LruCache;
import com.android.email2.ui.MailActivityEmail; import com.android.email.DebugUtils;
import com.android.mail.utils.LogUtils; import com.android.mail.utils.LogUtils;
import com.android.mail.utils.MatrixCursorWithCachedColumns; import com.android.mail.utils.MatrixCursorWithCachedColumns;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -185,7 +185,7 @@ public final class ContentCache {
} }
/*package*/ int invalidateTokens(String id) { /*package*/ int invalidateTokens(String id) {
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) { if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mLogTag, "============ Invalidate tokens for: " + id); LogUtils.d(mLogTag, "============ Invalidate tokens for: " + id);
} }
ArrayList<CacheToken> removeList = new ArrayList<CacheToken>(); ArrayList<CacheToken> removeList = new ArrayList<CacheToken>();
@ -204,7 +204,7 @@ public final class ContentCache {
} }
/*package*/ void invalidate() { /*package*/ void invalidate() {
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) { if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mLogTag, "============ List invalidated"); LogUtils.d(mLogTag, "============ List invalidated");
} }
for (CacheToken token: this) { for (CacheToken token: this) {
@ -215,7 +215,7 @@ public final class ContentCache {
/*package*/ boolean remove(CacheToken token) { /*package*/ boolean remove(CacheToken token) {
boolean result = super.remove(token); boolean result = super.remove(token);
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) { if (DebugUtils.DEBUG && DEBUG_TOKENS) {
if (result) { if (result) {
LogUtils.d(mLogTag, "============ Removing token for: " + token.mId); LogUtils.d(mLogTag, "============ Removing token for: " + token.mId);
} else { } else {
@ -228,7 +228,7 @@ public final class ContentCache {
public CacheToken add(String id) { public CacheToken add(String id) {
CacheToken token = new CacheToken(id); CacheToken token = new CacheToken(id);
super.add(token); super.add(token);
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) { if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mLogTag, "============ Taking token for: " + token.mId); LogUtils.d(mLogTag, "============ Taking token for: " + token.mId);
} }
return token; return token;
@ -483,14 +483,14 @@ public final class ContentCache {
CacheToken token) { CacheToken token) {
try { try {
if (!token.isValid()) { if (!token.isValid()) {
if (MailActivityEmail.DEBUG && DEBUG_CACHE) { if (DebugUtils.DEBUG && DEBUG_CACHE) {
LogUtils.d(mLogTag, "============ Stale token for " + id); LogUtils.d(mLogTag, "============ Stale token for " + id);
} }
mStats.mStaleCount++; mStats.mStaleCount++;
return c; return c;
} }
if (c != null && Arrays.equals(projection, mBaseProjection) && !sLockCache) { if (c != null && Arrays.equals(projection, mBaseProjection) && !sLockCache) {
if (MailActivityEmail.DEBUG && DEBUG_CACHE) { if (DebugUtils.DEBUG && DEBUG_CACHE) {
LogUtils.d(mLogTag, "============ Caching cursor for: " + id); LogUtils.d(mLogTag, "============ Caching cursor for: " + id);
} }
// If we've already cached this cursor, invalidate the older one // If we've already cached this cursor, invalidate the older one
@ -514,7 +514,7 @@ public final class ContentCache {
* @return a cursor based on cached values, or null if the row is not cached * @return a cursor based on cached values, or null if the row is not cached
*/ */
public synchronized Cursor getCachedCursor(String id, String[] projection) { public synchronized Cursor getCachedCursor(String id, String[] projection) {
if (MailActivityEmail.DEBUG && DEBUG_STATISTICS) { if (DebugUtils.DEBUG && DEBUG_STATISTICS) {
// Every 200 calls to getCursor, report cache statistics // Every 200 calls to getCursor, report cache statistics
dumpOnCount(200); dumpOnCount(200);
} }
@ -595,7 +595,7 @@ public final class ContentCache {
mLockMap.add(id); mLockMap.add(id);
// Invalidate current tokens // Invalidate current tokens
int count = mTokenList.invalidateTokens(id); int count = mTokenList.invalidateTokens(id);
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) { if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mTokenList.mLogTag, "============ Lock invalidated " + count + LogUtils.d(mTokenList.mLogTag, "============ Lock invalidated " + count +
" tokens for: " + id); " tokens for: " + id);
} }
@ -632,13 +632,13 @@ public final class ContentCache {
private void unlockImpl(String id, ContentValues values, boolean wasLocked) { private void unlockImpl(String id, ContentValues values, boolean wasLocked) {
Cursor c = get(id); Cursor c = get(id);
if (c != null) { if (c != null) {
if (MailActivityEmail.DEBUG && DEBUG_CACHE) { if (DebugUtils.DEBUG && DEBUG_CACHE) {
LogUtils.d(mLogTag, "=========== Unlocking cache for: " + id); LogUtils.d(mLogTag, "=========== Unlocking cache for: " + id);
} }
if (values != null && !sLockCache) { if (values != null && !sLockCache) {
MatrixCursor cursor = getMatrixCursor(id, mBaseProjection, values); MatrixCursor cursor = getMatrixCursor(id, mBaseProjection, values);
if (cursor != null) { if (cursor != null) {
if (MailActivityEmail.DEBUG && DEBUG_CACHE) { if (DebugUtils.DEBUG && DEBUG_CACHE) {
LogUtils.d(mLogTag, "=========== Recaching with new values: " + id); LogUtils.d(mLogTag, "=========== Recaching with new values: " + id);
} }
cursor.moveToFirst(); cursor.moveToFirst();

View File

@ -31,8 +31,8 @@ import android.provider.CalendarContract;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.email.DebugUtils;
import com.android.email.R; import com.android.email.R;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.mail.Address; import com.android.emailcommon.mail.Address;
import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.Credential; import com.android.emailcommon.provider.Credential;
@ -1628,7 +1628,7 @@ public final class DBHelper {
LEGACY_SCHEME_POP3.equals(protocol)) { LEGACY_SCHEME_POP3.equals(protocol)) {
// If this is a pop3 or imap account, create the account manager // If this is a pop3 or imap account, create the account manager
// account // account
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Create AccountManager account for " + protocol LogUtils.d(TAG, "Create AccountManager account for " + protocol
+ "account: " + "account: "
+ accountCursor.getString(V21_ACCOUNT_EMAIL)); + accountCursor.getString(V21_ACCOUNT_EMAIL));

View File

@ -63,6 +63,7 @@ import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import com.android.common.content.ProjectionMap; import com.android.common.content.ProjectionMap;
import com.android.email.DebugUtils;
import com.android.email.Preferences; import com.android.email.Preferences;
import com.android.email.R; import com.android.email.R;
import com.android.email.SecurityPolicy; import com.android.email.SecurityPolicy;
@ -514,7 +515,7 @@ public class EmailProvider extends ContentProvider
* Restore user Account and HostAuth data from our backup database * Restore user Account and HostAuth data from our backup database
*/ */
private static void restoreIfNeeded(Context context, SQLiteDatabase mainDatabase) { private static void restoreIfNeeded(Context context, SQLiteDatabase mainDatabase) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.w(TAG, "restoreIfNeeded..."); LogUtils.w(TAG, "restoreIfNeeded...");
} }
// Check for legacy backup // Check for legacy backup
@ -543,7 +544,7 @@ public class EmailProvider extends ContentProvider
if (DatabaseUtils.longForQuery(mainDatabase, if (DatabaseUtils.longForQuery(mainDatabase,
"SELECT EXISTS (SELECT ? FROM " + Account.TABLE_NAME + " )", "SELECT EXISTS (SELECT ? FROM " + Account.TABLE_NAME + " )",
EmailContent.ID_PROJECTION) > 0) { EmailContent.ID_PROJECTION) > 0) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.w(TAG, "restoreIfNeeded: Account exists."); LogUtils.w(TAG, "restoreIfNeeded: Account exists.");
} }
return; return;
@ -1011,6 +1012,7 @@ public class EmailProvider extends ContentProvider
Context context = getContext(); Context context = getContext();
EmailContent.init(context); EmailContent.init(context);
init(context); init(context);
DebugUtils.init(context);
// Do this last, so that EmailContent/EmailProvider are initialized // Do this last, so that EmailContent/EmailProvider are initialized
MailActivityEmail.setServicesEnabledAsync(context); MailActivityEmail.setServicesEnabledAsync(context);
reconcileAccountsAsync(context); reconcileAccountsAsync(context);

View File

@ -22,9 +22,8 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import com.android.email.NotificationController; import com.android.email.DebugUtils;
import com.android.email.ResourceHelper; import com.android.email.ResourceHelper;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Configuration; import com.android.emailcommon.Configuration;
import com.android.emailcommon.Device; import com.android.emailcommon.Device;
import com.android.emailcommon.VendorPolicyLoader; import com.android.emailcommon.VendorPolicyLoader;
@ -62,7 +61,7 @@ public class AccountService extends Service {
// Make sure remote services are running (re: lifecycle) // Make sure remote services are running (re: lifecycle)
EmailServiceUtils.startRemoteServices(mContext); EmailServiceUtils.startRemoteServices(mContext);
// Send current logging flags // Send current logging flags
MailActivityEmail.updateLoggingFlags(mContext); DebugUtils.updateLoggingFlags(mContext);
}}); }});
return Device.getDeviceId(mContext); return Device.getDeviceId(mContext);
} catch (IOException e) { } catch (IOException e) {

View File

@ -25,11 +25,11 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import com.android.email.DebugUtils;
import com.android.email.NotificationController; import com.android.email.NotificationController;
import com.android.email.mail.Sender; import com.android.email.mail.Sender;
import com.android.email.mail.Store; import com.android.email.mail.Store;
import com.android.email.service.EmailServiceUtils.EmailServiceInfo; import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.TrafficFlags; import com.android.emailcommon.TrafficFlags;
import com.android.emailcommon.internet.MimeBodyPart; import com.android.emailcommon.internet.MimeBodyPart;
@ -462,7 +462,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
messageId = c.getLong(0); messageId = c.getLong(0);
// Don't send messages with unloaded attachments // Don't send messages with unloaded attachments
if (Utility.hasUnloadedAttachments(context, messageId)) { if (Utility.hasUnloadedAttachments(context, messageId)) {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "Can't send #" + messageId + LogUtils.d(Logging.LOG_TAG, "Can't send #" + messageId +
"; unloaded attachments"); "; unloaded attachments");
} }

View File

@ -30,12 +30,12 @@ import android.os.SystemClock;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import com.android.email.DebugUtils;
import com.android.email.LegacyConversions; import com.android.email.LegacyConversions;
import com.android.email.NotificationController; import com.android.email.NotificationController;
import com.android.email.R; import com.android.email.R;
import com.android.email.mail.Store; import com.android.email.mail.Store;
import com.android.email.provider.Utilities; import com.android.email.provider.Utilities;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.TrafficFlags; import com.android.emailcommon.TrafficFlags;
import com.android.emailcommon.internet.MimeUtility; import com.android.emailcommon.internet.MimeUtility;
@ -850,7 +850,7 @@ public class ImapService extends Service {
} catch (MessagingException me) { } catch (MessagingException me) {
// Presumably an error here is an account connection failure, so there is // Presumably an error here is an account connection failure, so there is
// no point in continuing through the rest of the pending updates. // no point in continuing through the rest of the pending updates.
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "Unable to process pending delete for id=" LogUtils.d(Logging.LOG_TAG, "Unable to process pending delete for id="
+ lastMessageId + ": " + me); + lastMessageId + ": " + me);
} }
@ -926,7 +926,7 @@ public class ImapService extends Service {
} catch (MessagingException me) { } catch (MessagingException me) {
// Presumably an error here is an account connection failure, so there is // Presumably an error here is an account connection failure, so there is
// no point in continuing through the rest of the pending updates. // no point in continuing through the rest of the pending updates.
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "Unable to process pending upsync for id=" LogUtils.d(Logging.LOG_TAG, "Unable to process pending upsync for id="
+ lastMessageId + ": " + me); + lastMessageId + ": " + me);
} }
@ -1009,7 +1009,7 @@ public class ImapService extends Service {
} catch (MessagingException me) { } catch (MessagingException me) {
// Presumably an error here is an account connection failure, so there is // Presumably an error here is an account connection failure, so there is
// no point in continuing through the rest of the pending updates. // no point in continuing through the rest of the pending updates.
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "Unable to process pending update for id=" LogUtils.d(Logging.LOG_TAG, "Unable to process pending update for id="
+ lastMessageId + ": " + me); + lastMessageId + ": " + me);
} }
@ -1113,7 +1113,7 @@ public class ImapService extends Service {
if (remoteMessage == null) { if (remoteMessage == null) {
return; return;
} }
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, LogUtils.d(Logging.LOG_TAG,
"Update for msg id=" + newMessage.mId "Update for msg id=" + newMessage.mId
+ " read=" + newMessage.mFlagRead + " read=" + newMessage.mFlagRead

View File

@ -28,13 +28,13 @@ import android.net.Uri;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import com.android.email.DebugUtils;
import com.android.email.NotificationController; import com.android.email.NotificationController;
import com.android.email.mail.Store; import com.android.email.mail.Store;
import com.android.email.mail.store.Pop3Store; import com.android.email.mail.store.Pop3Store;
import com.android.email.mail.store.Pop3Store.Pop3Folder; import com.android.email.mail.store.Pop3Store.Pop3Folder;
import com.android.email.mail.store.Pop3Store.Pop3Message; import com.android.email.mail.store.Pop3Store.Pop3Message;
import com.android.email.provider.Utilities; import com.android.email.provider.Utilities;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.TrafficFlags; import com.android.emailcommon.TrafficFlags;
import com.android.emailcommon.mail.AuthenticationFailedException; import com.android.emailcommon.mail.AuthenticationFailedException;
@ -166,7 +166,7 @@ public class Pop3Service extends Service {
Pop3Folder remoteFolder, ArrayList<Pop3Message> unsyncedMessages, Pop3Folder remoteFolder, ArrayList<Pop3Message> unsyncedMessages,
final Mailbox toMailbox) throws MessagingException { final Mailbox toMailbox) throws MessagingException {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Loading " + unsyncedMessages.size() + " unsynced messages"); LogUtils.d(TAG, "Loading " + unsyncedMessages.size() + " unsynced messages");
} }
@ -186,7 +186,7 @@ public class Pop3Service extends Service {
// user requests it. // user requests it.
flag = EmailContent.Message.FLAG_LOADED_PARTIAL; flag = EmailContent.Message.FLAG_LOADED_PARTIAL;
} }
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Message is " + (message.isComplete() ? "" : "NOT ") LogUtils.d(TAG, "Message is " + (message.isComplete() ? "" : "NOT ")
+ "complete"); + "complete");
} }
@ -378,7 +378,7 @@ public class Pop3Service extends Service {
} }
} }
} else { } else {
if (MailActivityEmail.DEBUG) { if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "*** Message count is zero??"); LogUtils.d(TAG, "*** Message count is zero??");
} }
remoteFolder.close(false); remoteFolder.close(false);

View File

@ -48,27 +48,9 @@ import com.android.mail.utils.LogUtils;
import com.android.mail.utils.Utils; import com.android.mail.utils.Utils;
public class MailActivityEmail extends com.android.mail.ui.MailActivity { public class MailActivityEmail extends com.android.mail.ui.MailActivity {
/**
* If this is enabled there will be additional logging information sent to
* LogUtils.d, including protocol dumps.
*
* This should only be used for logs that are useful for debbuging user problems,
* not for internal/development logs.
*
* This can be enabled by typing "debug" in the AccountFolderList activity.
* Changing the value to 'true' here will likely have no effect at all!
*
* TODO: rename this to sUserDebug, and rename LOGD below to DEBUG.
*/
public static boolean DEBUG;
public static final String LOG_TAG = LogTag.getLogTag(); public static final String LOG_TAG = LogTag.getLogTag();
// Exchange debugging flags (passed to Exchange, when available, via EmailServiceProxy)
public static boolean DEBUG_EXCHANGE;
public static boolean DEBUG_VERBOSE;
public static boolean DEBUG_FILE;
private static final int MATCH_LEGACY_SHORTCUT_INTENT = 1; private static final int MATCH_LEGACY_SHORTCUT_INTENT = 1;
/** /**
* A matcher for data URI's that specify conversation list info. * A matcher for data URI's that specify conversation list info.
@ -177,35 +159,13 @@ public class MailActivityEmail extends com.android.mail.ui.MailActivity {
} }
super.onCreate(bundle); super.onCreate(bundle);
final Preferences prefs = Preferences.getPreferences(this);
DEBUG = prefs.getEnableDebugLogging();
enableStrictMode(prefs.getEnableStrictMode());
TempDirectory.setTempDirectory(this); TempDirectory.setTempDirectory(this);
// Enable logging in the EAS service, so it starts up as early as possible.
updateLoggingFlags(this);
// Make sure all required services are running when the app is started (can prevent // Make sure all required services are running when the app is started (can prevent
// issues after an adb sync/install) // issues after an adb sync/install)
setServicesEnabledAsync(this); setServicesEnabledAsync(this);
} }
/**
* 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 verboseLogging =
prefs.getEnableExchangeLogging() ? EmailServiceProxy.DEBUG_VERBOSE_BIT : 0;
int fileLogging =
prefs.getEnableExchangeFileLogging() ? EmailServiceProxy.DEBUG_FILE_BIT : 0;
int enableStrictMode =
prefs.getEnableStrictMode() ? EmailServiceProxy.DEBUG_ENABLE_STRICT_MODE : 0;
int debugBits = debugLogging | verboseLogging | fileLogging | enableStrictMode;
EmailServiceUtils.setRemoteServicesLogging(context, debugBits);
}
/** /**
* Internal, utility method for logging. * Internal, utility method for logging.
* The calls to log() must be guarded with "if (Email.LOGD)" for performance reasons. * The calls to log() must be guarded with "if (Email.LOGD)" for performance reasons.
@ -214,10 +174,6 @@ public class MailActivityEmail extends com.android.mail.ui.MailActivity {
LogUtils.d(Logging.LOG_TAG, message); LogUtils.d(Logging.LOG_TAG, message);
} }
public static void enableStrictMode(boolean enabled) {
Utility.enableStrictMode(enabled);
}
private Intent getViewIntent(long accountId, long mailboxId) { private Intent getViewIntent(long accountId, long mailboxId) {
final ContentResolver contentResolver = getContentResolver(); final ContentResolver contentResolver = getContentResolver();