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

* commit '30d8d696eaf5654ccc3ddb3e2714ebcd972451a9':
  Put debug screen back into settings
This commit is contained in:
Martin Hibdon 2014-11-02 17:29:20 +00:00 committed by Android Git Automerger
commit 33ab7b3453
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;
// Standard debugging
public static final int DEBUG_BIT = 1;
public static final int DEBUG_BIT = 0x01;
// Verbose (parser) logging
public static final int DEBUG_VERBOSE_BIT = 2;
public static final int DEBUG_EXCHANGE_BIT = 0x02;
// File (SD card) logging
public static final int DEBUG_FILE_BIT = 4;
public static final int DEBUG_FILE_BIT = 0x04;
// 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
public EmailServiceProxy(Context _context, Class<?> _class) {

View File

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

View File

@ -31,8 +31,6 @@
<!-- Name of application on Home screen -->
<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 -->
<skip />
@ -83,12 +81,14 @@
<!-- In the UI, the unread will be displayed with this name [CHAR LIMIT=15] -->
<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 -->
<string name="debug_enable_debug_logging_label" translatable="false">
Enable extra debug logging?</string>
<!-- Do Not Translate. Checkbox label, shown only on debug screen -->
<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 -->
<string name="debug_enable_file_logging_label" translatable="false">
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.WakeLock;
import com.android.email2.ui.MailActivityEmail;
import com.android.mail.utils.LogUtils;
/**
@ -181,14 +180,14 @@ public class EmailConnectivityManager extends BroadcastReceiver {
if (info != null) {
// We're done if there's an active network
if (waiting) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, mName + ": Connectivity wait ended");
}
}
return;
} else {
if (!waiting) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, mName + ": Connectivity waiting...");
}
waiting = true;

View File

@ -36,7 +36,6 @@ import com.android.email.provider.AccountReconciler;
import com.android.email.provider.EmailProvider;
import com.android.email.service.EmailBroadcastProcessorService;
import com.android.email.service.EmailServiceUtils;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent;
@ -140,7 +139,7 @@ public class SecurityPolicy {
try {
while (c.moveToNext()) {
policy.restore(c);
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Aggregate from: " + policy);
}
aggregate.mPasswordMinLength =
@ -185,12 +184,12 @@ public class SecurityPolicy {
aggregate.mPasswordExpirationDays = 0;
if (aggregate.mPasswordComplexChars == Integer.MIN_VALUE)
aggregate.mPasswordComplexChars = 0;
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Calculated Aggregate: " + aggregate);
}
return aggregate;
}
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "Calculated Aggregate: no policy");
}
return Policy.NO_POLICY;
@ -232,7 +231,7 @@ public class SecurityPolicy {
* rollbacks.
*/
public void reducePolicies() {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "reducePolicies");
}
policiesUpdated();
@ -247,7 +246,7 @@ public class SecurityPolicy {
*/
public boolean isActive(Policy policy) {
int reasons = getInactiveReasons(policy);
if (MailActivityEmail.DEBUG && (reasons != 0)) {
if (DebugUtils.DEBUG && (reasons != 0)) {
StringBuilder sb = new StringBuilder("isActive for " + policy + ": ");
sb.append("FALSE -> ");
if ((reasons & INACTIVE_NEED_ACTIVATION) != 0) {
@ -407,12 +406,12 @@ public class SecurityPolicy {
Policy aggregatePolicy = getAggregatePolicy();
// if empty set, detach from policy manager
if (aggregatePolicy == Policy.NO_POLICY) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "setActivePolicies: none, remove admin");
}
dpm.removeActiveAdmin(mAdminName);
} else if (isActiveAdmin()) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(TAG, "setActivePolicies: " + aggregatePolicy);
}
// set each policy in the policy manager
@ -492,7 +491,7 @@ public class SecurityPolicy {
if (account.mPolicyKey == 0) return;
Policy policy = Policy.restorePolicyWithId(mContext, account.mPolicyKey);
if (policy == null) return;
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
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.Handler;
import com.android.email.DebugUtils;
import com.android.email.R;
import com.android.email.SecurityPolicy;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.provider.Policy;
@ -292,7 +292,7 @@ public class AccountSecurity extends Activity {
PasswordExpirationDialog dialog =
PasswordExpirationDialog.newInstance(mAccount.getDisplayName(),
passwordExpired);
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Showing password expiration dialog");
}
dialog.show(fm, "password_expiration");
@ -308,7 +308,7 @@ public class AccountSecurity extends Activity {
if (fm.findFragmentByTag("security_needed") == null) {
SecurityNeededDialog dialog =
SecurityNeededDialog.newInstance(mAccount.getDisplayName());
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Showing security needed dialog");
}
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
if (!security.isActiveAdmin()) {
if (mTriedAddAdministrator) {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Not active admin: repost notification");
}
repostNotification(account, security);
@ -359,13 +359,13 @@ public class AccountSecurity extends Activity {
// retrieve name of server for the format string
final HostAuth hostAuth = account.mHostAuthRecv;
if (hostAuth == null) {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "No HostAuth: repost notification");
}
repostNotification(account, security);
finish();
} else {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Not active admin: post initial notification");
}
// 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
// DevicePolicyManager (the current system security level).
if (security.isActive(null)) {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Security active; clear holds");
}
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
if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_PASSWORD) != 0) {
if (mTriedSetPassword) {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Password needed; repost notification");
}
repostNotification(account, security);
finish();
} else {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Password needed; request it via DPM");
}
mTriedSetPassword = true;
@ -424,13 +424,13 @@ public class AccountSecurity extends Activity {
// Step 6. If encryption is needed, try to have the user set it
if ((inactiveReasons & SecurityPolicy.INACTIVE_NEED_ENCRYPTION) != 0) {
if (mTriedSetEncryption) {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Encryption needed; repost notification");
}
repostNotification(account, security);
finish();
} else {
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Encryption needed; request it via DPM");
}
mTriedSetEncryption = true;
@ -442,7 +442,7 @@ public class AccountSecurity extends Activity {
}
// 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");
}
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.setPositiveButton(android.R.string.ok, this);
b.setNegativeButton(android.R.string.cancel, this);
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "Posting security needed dialog");
}
return b.create();
@ -518,13 +518,13 @@ public class AccountSecurity extends Activity {
}
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "User accepts; advance to next step");
}
activity.tryAdvanceSecurity(activity.mAccount);
break;
case DialogInterface.BUTTON_NEGATIVE:
if (MailActivityEmail.DEBUG || DEBUG) {
if (DebugUtils.DEBUG || DEBUG) {
LogUtils.d(TAG, "User declines; repost notification");
}
AccountSecurity.repostNotification(

View File

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

View File

@ -19,6 +19,7 @@ package com.android.email.mail.store;
import android.text.TextUtils;
import android.util.Base64;
import com.android.email.DebugUtils;
import com.android.email.mail.internet.AuthenticationCache;
import com.android.email.mail.store.ImapStore.ImapException;
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.transport.DiscourseLogger;
import com.android.email.mail.transport.MailTransport;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.AuthenticationFailedException;
import com.android.emailcommon.mail.CertificateValidationException;
@ -179,7 +179,7 @@ class ImapConnection {
mImapStore.ensurePrefixIsValid();
} catch (SSLException e) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e, "SSLException");
}
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
// 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.
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe, "IOException");
}
throw ioe;
@ -442,7 +442,7 @@ class ImapConnection {
executeSimpleCommand(mIdPhrase);
} catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem.
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
}
} catch (IOException ioe) {
@ -467,7 +467,7 @@ class ImapConnection {
responseList = executeSimpleCommand(ImapConstants.NAMESPACE);
} catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem.
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
}
} catch (IOException ioe) {
@ -501,7 +501,7 @@ class ImapConnection {
executeSimpleCommand(getLoginPhrase(), true);
}
} catch (ImapException ie) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
}
@ -588,7 +588,7 @@ class ImapConnection {
responseList = executeSimpleCommand(ImapConstants.LIST + " \"\" \"\"");
} catch (ImapException ie) {
// Log for debugging, but this is not a fatal problem.
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ie, "ImapException");
}
} catch (IOException ioe) {
@ -620,7 +620,7 @@ class ImapConnection {
// Per RFC requirement (3501-6.2.1) gather new capabilities
return(queryCapabilities());
} else {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "TLS not supported but required");
}
throw new MessagingException(MessagingException.TLS_REQUIRED);

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@ package com.android.email.mail.transport;
import android.content.Context;
import com.android.email2.ui.MailActivityEmail;
import com.android.email.DebugUtils;
import com.android.emailcommon.Logging;
import com.android.emailcommon.mail.CertificateValidationException;
import com.android.emailcommon.mail.MessagingException;
@ -103,7 +103,7 @@ public class MailTransport {
* an SSL connection if indicated.
*/
public void open() throws MessagingException, CertificateValidationException {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "*** " + mDebugLabel + " open " +
getHost() + ":" + String.valueOf(getPort()));
}
@ -125,17 +125,17 @@ public class MailTransport {
mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512);
mSocket.setSoTimeout(SOCKET_READ_TIMEOUT);
} catch (SSLException e) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e.toString());
}
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, ioe.toString());
}
throw new MessagingException(MessagingException.IOERROR, ioe.toString());
} catch (IllegalArgumentException iae) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, iae.toString());
}
throw new MessagingException(MessagingException.UNSPECIFIED_EXCEPTION, iae.toString());
@ -159,12 +159,12 @@ public class MailTransport {
mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512);
} catch (SSLException e) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e.toString());
}
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, 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.
*/
public void writeLine(String s, String sensitiveReplacement) throws IOException {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
if (sensitiveReplacement != null && !Logging.DEBUG_SENSITIVE) {
LogUtils.d(Logging.LOG_TAG, ">>> " + sensitiveReplacement);
} else {
@ -300,11 +300,11 @@ public class MailTransport {
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.");
}
String ret = sb.toString();
if (loggable && MailActivityEmail.DEBUG) {
if (loggable && DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "<<< " + ret);
}
return ret;

View File

@ -19,9 +19,9 @@ package com.android.email.mail.transport;
import android.content.Context;
import android.util.Base64;
import com.android.email.DebugUtils;
import com.android.email.mail.Sender;
import com.android.email.mail.internet.AuthenticationCache;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging;
import com.android.emailcommon.internet.Rfc822Output;
import com.android.emailcommon.mail.Address;
@ -128,7 +128,7 @@ public class SmtpSender extends Sender {
*/
result = executeSimpleCommand("EHLO " + localHost);
} else {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, "TLS not supported but 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.
}
} catch (SSLException e) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e.toString());
}
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, 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.util.LruCache;
import com.android.email2.ui.MailActivityEmail;
import com.android.email.DebugUtils;
import com.android.mail.utils.LogUtils;
import com.android.mail.utils.MatrixCursorWithCachedColumns;
import com.google.common.annotations.VisibleForTesting;
@ -185,7 +185,7 @@ public final class ContentCache {
}
/*package*/ int invalidateTokens(String id) {
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) {
if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mLogTag, "============ Invalidate tokens for: " + id);
}
ArrayList<CacheToken> removeList = new ArrayList<CacheToken>();
@ -204,7 +204,7 @@ public final class ContentCache {
}
/*package*/ void invalidate() {
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) {
if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mLogTag, "============ List invalidated");
}
for (CacheToken token: this) {
@ -215,7 +215,7 @@ public final class ContentCache {
/*package*/ boolean remove(CacheToken token) {
boolean result = super.remove(token);
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) {
if (DebugUtils.DEBUG && DEBUG_TOKENS) {
if (result) {
LogUtils.d(mLogTag, "============ Removing token for: " + token.mId);
} else {
@ -228,7 +228,7 @@ public final class ContentCache {
public CacheToken add(String id) {
CacheToken token = new CacheToken(id);
super.add(token);
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) {
if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mLogTag, "============ Taking token for: " + token.mId);
}
return token;
@ -483,14 +483,14 @@ public final class ContentCache {
CacheToken token) {
try {
if (!token.isValid()) {
if (MailActivityEmail.DEBUG && DEBUG_CACHE) {
if (DebugUtils.DEBUG && DEBUG_CACHE) {
LogUtils.d(mLogTag, "============ Stale token for " + id);
}
mStats.mStaleCount++;
return c;
}
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);
}
// 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
*/
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
dumpOnCount(200);
}
@ -595,7 +595,7 @@ public final class ContentCache {
mLockMap.add(id);
// Invalidate current tokens
int count = mTokenList.invalidateTokens(id);
if (MailActivityEmail.DEBUG && DEBUG_TOKENS) {
if (DebugUtils.DEBUG && DEBUG_TOKENS) {
LogUtils.d(mTokenList.mLogTag, "============ Lock invalidated " + count +
" tokens for: " + id);
}
@ -632,13 +632,13 @@ public final class ContentCache {
private void unlockImpl(String id, ContentValues values, boolean wasLocked) {
Cursor c = get(id);
if (c != null) {
if (MailActivityEmail.DEBUG && DEBUG_CACHE) {
if (DebugUtils.DEBUG && DEBUG_CACHE) {
LogUtils.d(mLogTag, "=========== Unlocking cache for: " + id);
}
if (values != null && !sLockCache) {
MatrixCursor cursor = getMatrixCursor(id, mBaseProjection, values);
if (cursor != null) {
if (MailActivityEmail.DEBUG && DEBUG_CACHE) {
if (DebugUtils.DEBUG && DEBUG_CACHE) {
LogUtils.d(mLogTag, "=========== Recaching with new values: " + id);
}
cursor.moveToFirst();

View File

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

View File

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

View File

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

View File

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

View File

@ -30,12 +30,12 @@ import android.os.SystemClock;
import android.text.TextUtils;
import android.text.format.DateUtils;
import com.android.email.DebugUtils;
import com.android.email.LegacyConversions;
import com.android.email.NotificationController;
import com.android.email.R;
import com.android.email.mail.Store;
import com.android.email.provider.Utilities;
import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging;
import com.android.emailcommon.TrafficFlags;
import com.android.emailcommon.internet.MimeUtility;
@ -850,7 +850,7 @@ public class ImapService extends Service {
} catch (MessagingException me) {
// Presumably an error here is an account connection failure, so there is
// 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="
+ lastMessageId + ": " + me);
}
@ -926,7 +926,7 @@ public class ImapService extends Service {
} catch (MessagingException me) {
// Presumably an error here is an account connection failure, so there is
// 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="
+ lastMessageId + ": " + me);
}
@ -1009,7 +1009,7 @@ public class ImapService extends Service {
} catch (MessagingException me) {
// Presumably an error here is an account connection failure, so there is
// 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="
+ lastMessageId + ": " + me);
}
@ -1113,7 +1113,7 @@ public class ImapService extends Service {
if (remoteMessage == null) {
return;
}
if (MailActivityEmail.DEBUG) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG,
"Update for msg id=" + newMessage.mId
+ " read=" + newMessage.mFlagRead

View File

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

View File

@ -48,27 +48,9 @@ import com.android.mail.utils.LogUtils;
import com.android.mail.utils.Utils;
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();
// 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;
/**
* 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);
final Preferences prefs = Preferences.getPreferences(this);
DEBUG = prefs.getEnableDebugLogging();
enableStrictMode(prefs.getEnableStrictMode());
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
// issues after an adb sync/install)
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.
* 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);
}
public static void enableStrictMode(boolean enabled) {
Utility.enableStrictMode(enabled);
}
private Intent getViewIntent(long accountId, long mailboxId) {
final ContentResolver contentResolver = getContentResolver();