Remove conditional logging from call sites

This commit is contained in:
cketti 2017-03-02 18:04:53 +01:00 committed by Vincent Breitmoser
parent eb61829003
commit 021b24c93f
46 changed files with 364 additions and 722 deletions

View file

@ -571,20 +571,21 @@ public class K9 extends Application {
intent.putExtra(K9.Intents.EmailReceived.EXTRA_SUBJECT, message.getSubject()); intent.putExtra(K9.Intents.EmailReceived.EXTRA_SUBJECT, message.getSubject());
intent.putExtra(K9.Intents.EmailReceived.EXTRA_FROM_SELF, account.isAnIdentity(message.getFrom())); intent.putExtra(K9.Intents.EmailReceived.EXTRA_FROM_SELF, account.isAnIdentity(message.getFrom()));
K9.this.sendBroadcast(intent); K9.this.sendBroadcast(intent);
if (K9.DEBUG)
Timber.d("Broadcasted: action=%s account=%s folder=%s message uid=%s", Timber.d("Broadcasted: action=%s account=%s folder=%s message uid=%s",
action, account.getDescription(), folder, message.getUid()); action,
account.getDescription(),
folder,
message.getUid());
} }
private void updateUnreadWidget() { private void updateUnreadWidget() {
try { try {
UnreadWidgetProvider.updateUnreadCount(K9.this); UnreadWidgetProvider.updateUnreadCount(K9.this);
} catch (Exception e) { } catch (Exception e) {
if (K9.DEBUG) {
Timber.e(e, "Error while updating unread widget(s)"); Timber.e(e, "Error while updating unread widget(s)");
} }
} }
}
private void updateMailListWidget() { private void updateMailListWidget() {
try { try {
@ -592,7 +593,7 @@ public class K9 extends Application {
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
throw e; throw e;
} else if (K9.DEBUG) { } else {
Timber.e(e, "Error while updating message list widget"); Timber.e(e, "Error while updating message list widget");
} }
} }
@ -802,9 +803,8 @@ public class K9 extends Application {
protected void notifyObservers() { protected void notifyObservers() {
synchronized (observers) { synchronized (observers) {
for (final ApplicationAware aware : observers) { for (final ApplicationAware aware : observers) {
if (K9.DEBUG) {
Timber.v("Initializing observer: %s", aware); Timber.v("Initializing observer: %s", aware);
}
try { try {
aware.initializeComponent(this); aware.initializeComponent(this);
} catch (Exception e) { } catch (Exception e) {

View file

@ -792,9 +792,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
private void onAccountChosen(Account account, Identity identity) { private void onAccountChosen(Account account, Identity identity) {
if (!this.account.equals(account)) { if (!this.account.equals(account)) {
if (K9.DEBUG) {
Timber.v("Switching account from %s to %s", this.account, account); Timber.v("Switching account from %s to %s", this.account, account);
}
// on draft edit, make sure we don't keep previous message UID // on draft edit, make sure we don't keep previous message UID
if (action == Action.EDIT_DRAFT) { if (action == Action.EDIT_DRAFT) {
@ -812,15 +810,12 @@ public class MessageCompose extends K9Activity implements OnClickListener,
// actual account switch // actual account switch
this.account = account; this.account = account;
if (K9.DEBUG) {
Timber.v("Account switch, saving new draft in new account"); Timber.v("Account switch, saving new draft in new account");
}
checkToSaveDraftImplicitly(); checkToSaveDraftImplicitly();
if (previousDraftId != INVALID_DRAFT_ID) { if (previousDraftId != INVALID_DRAFT_ID) {
if (K9.DEBUG) {
Timber.v("Account switch, deleting draft from previous account: %d", previousDraftId); Timber.v("Account switch, deleting draft from previous account: %d", previousDraftId);
}
MessagingController.getInstance(getApplication()).deleteDraft(previousAccount, MessagingController.getInstance(getApplication()).deleteDraft(previousAccount,
previousDraftId); previousDraftId);
} }
@ -1199,10 +1194,8 @@ public class MessageCompose extends K9Activity implements OnClickListener,
} }
} else { } else {
if (K9.DEBUG) {
Timber.d("could not get Message-ID."); Timber.d("could not get Message-ID.");
} }
}
// Quote the message and setup the UI. // Quote the message and setup the UI.
quotedMessagePresenter.initFromReplyToMessage(messageViewInfo, action); quotedMessagePresenter.initFromReplyToMessage(messageViewInfo, action);
@ -1235,10 +1228,8 @@ public class MessageCompose extends K9Activity implements OnClickListener,
repliedToMessageId = message.getMessageId(); repliedToMessageId = message.getMessageId();
referencedMessageIds = repliedToMessageId; referencedMessageIds = repliedToMessageId;
} else { } else {
if (K9.DEBUG) {
Timber.d("could not get Message-ID."); Timber.d("could not get Message-ID.");
} }
}
// Quote the message and setup the UI. // Quote the message and setup the UI.
quotedMessagePresenter.processMessageToForward(messageViewInfo); quotedMessagePresenter.processMessageToForward(messageViewInfo);
@ -1369,12 +1360,11 @@ public class MessageCompose extends K9Activity implements OnClickListener,
**/ **/
private void updateReferencedMessage() { private void updateReferencedMessage() {
if (messageReference != null && messageReference.getFlag() != null) { if (messageReference != null && messageReference.getFlag() != null) {
if (K9.DEBUG) {
Timber.d("Setting referenced message (%s, %s) flag to %s", Timber.d("Setting referenced message (%s, %s) flag to %s",
messageReference.getFolderName(), messageReference.getFolderName(),
messageReference.getUid(), messageReference.getUid(),
messageReference.getFlag()); messageReference.getFlag());
}
final Account account = Preferences.getPreferences(context) final Account account = Preferences.getPreferences(context)
.getAccount(messageReference.getAccountUuid()); .getAccount(messageReference.getAccountUuid());
final String folderName = messageReference.getFolderName(); final String folderName = messageReference.getFolderName();

View file

@ -757,7 +757,6 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
// Swallow these events too to avoid the audible notification of a volume change // Swallow these events too to avoid the audible notification of a volume change
if (K9.useVolumeKeysForListNavigationEnabled()) { if (K9.useVolumeKeysForListNavigationEnabled()) {
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
if (K9.DEBUG)
Timber.v("Swallowed key up."); Timber.v("Swallowed key up.");
return true; return true;
} }

View file

@ -58,9 +58,7 @@ public class AttachmentContentLoader extends AsyncTaskLoader<Attachment> {
File file = File.createTempFile(FILENAME_PREFIX, null, context.getCacheDir()); File file = File.createTempFile(FILENAME_PREFIX, null, context.getCacheDir());
file.deleteOnExit(); file.deleteOnExit();
if (K9.DEBUG) {
Timber.v("Saving attachment to %s", file.getAbsolutePath()); Timber.v("Saving attachment to %s", file.getAbsolutePath());
}
SafeContentResolver safeContentResolver = SafeContentResolverCompat.newInstance(context); SafeContentResolver safeContentResolver = SafeContentResolverCompat.newInstance(context);
InputStream in = safeContentResolver.openInputStream(sourceAttachment.uri); InputStream in = safeContentResolver.openInputStream(sourceAttachment.uri);

View file

@ -53,9 +53,7 @@ public class TemporaryAttachmentStore {
for (File file : files) { for (File file : files) {
if (file.lastModified() < cutOffTime) { if (file.lastModified() < cutOffTime) {
if (file.delete()) { if (file.delete()) {
if (K9.DEBUG) {
Timber.d("Deleted from temporary attachment store: %s", file.getName()); Timber.d("Deleted from temporary attachment store: %s", file.getName());
}
} else { } else {
Timber.w("Couldn't delete from temporary attachment store: %s", file.getName()); Timber.w("Couldn't delete from temporary attachment store: %s", file.getName());
} }

View file

@ -199,12 +199,10 @@ public class MessagingController {
if (command != null) { if (command != null) {
commandDescription = command.description; commandDescription = command.description;
if (K9.DEBUG) {
Timber.i("Running command '%s', seq = %s (%s priority)", Timber.i("Running command '%s', seq = %s (%s priority)",
command.description, command.description,
command.sequence, command.sequence,
command.isForegroundPriority ? "foreground" : "background"); command.isForegroundPriority ? "foreground" : "background");
}
try { try {
command.runnable.run(); command.runnable.run();
@ -224,10 +222,8 @@ public class MessagingController {
}.start(); }.start();
} }
if (K9.DEBUG) {
Timber.i(" Command '%s' completed", command.description); Timber.i(" Command '%s' completed", command.description);
} }
}
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "Error running command '%s'", commandDescription); Timber.e(e, "Error running command '%s'", commandDescription);
} }
@ -561,9 +557,7 @@ public class MessagingController {
public Future<?> searchRemoteMessages(final String acctUuid, final String folderName, final String query, public Future<?> searchRemoteMessages(final String acctUuid, final String folderName, final String query,
final Set<Flag> requiredFlags, final Set<Flag> forbiddenFlags, final MessagingListener listener) { final Set<Flag> requiredFlags, final Set<Flag> forbiddenFlags, final MessagingListener listener) {
if (K9.DEBUG) {
Timber.i("searchRemoteMessages (acct = %s, folderName = %s, query = %s)", acctUuid, folderName, query); Timber.i("searchRemoteMessages (acct = %s, folderName = %s, query = %s)", acctUuid, folderName, query);
}
return threadPool.submit(new Runnable() { return threadPool.submit(new Runnable() {
@Override @Override
@ -599,9 +593,7 @@ public class MessagingController {
List<Message> messages = remoteFolder.search(query, requiredFlags, forbiddenFlags); List<Message> messages = remoteFolder.search(query, requiredFlags, forbiddenFlags);
if (K9.DEBUG) {
Timber.i("Remote search got %d results", messages.size()); Timber.i("Remote search got %d results", messages.size());
}
// There's no need to fetch messages already completely downloaded // There's no need to fetch messages already completely downloaded
List<Message> remoteMessages = localFolder.extractNewMessages(messages); List<Message> remoteMessages = localFolder.extractNewMessages(messages);
@ -740,9 +732,7 @@ public class MessagingController {
Folder remoteFolder = null; Folder remoteFolder = null;
LocalFolder tLocalFolder = null; LocalFolder tLocalFolder = null;
if (K9.DEBUG) {
Timber.i("Synchronizing folder %s:%s", account.getDescription(), folder); Timber.i("Synchronizing folder %s:%s", account.getDescription(), folder);
}
for (MessagingListener l : getListeners(listener)) { for (MessagingListener l : getListeners(listener)) {
l.synchronizeMailboxStarted(account, folder); l.synchronizeMailboxStarted(account, folder);
@ -760,9 +750,7 @@ public class MessagingController {
Exception commandException = null; Exception commandException = null;
try { try {
if (K9.DEBUG) {
Timber.d("SYNC: About to process pending commands for account %s", account.getDescription()); Timber.d("SYNC: About to process pending commands for account %s", account.getDescription());
}
try { try {
processPendingCommandsSynchronous(account); processPendingCommandsSynchronous(account);
@ -777,9 +765,7 @@ public class MessagingController {
* Get the message list from the local store and create an index of * Get the message list from the local store and create an index of
* the uids within the list. * the uids within the list.
*/ */
if (K9.DEBUG) {
Timber.v("SYNC: About to get local folder %s", folder); Timber.v("SYNC: About to get local folder %s", folder);
}
final LocalStore localStore = account.getLocalStore(); final LocalStore localStore = account.getLocalStore();
tLocalFolder = localStore.getFolder(folder); tLocalFolder = localStore.getFolder(folder);
@ -789,16 +775,12 @@ public class MessagingController {
Map<String, Long> localUidMap = localFolder.getAllMessagesAndEffectiveDates(); Map<String, Long> localUidMap = localFolder.getAllMessagesAndEffectiveDates();
if (providedRemoteFolder != null) { if (providedRemoteFolder != null) {
if (K9.DEBUG) {
Timber.v("SYNC: using providedRemoteFolder %s", folder); Timber.v("SYNC: using providedRemoteFolder %s", folder);
}
remoteFolder = providedRemoteFolder; remoteFolder = providedRemoteFolder;
} else { } else {
Store remoteStore = account.getRemoteStore(); Store remoteStore = account.getRemoteStore();
if (K9.DEBUG) {
Timber.v("SYNC: About to get remote folder %s", folder); Timber.v("SYNC: About to get remote folder %s", folder);
}
remoteFolder = remoteStore.getFolder(folder); remoteFolder = remoteStore.getFolder(folder);
if (!verifyOrCreateRemoteSpecialFolder(account, folder, remoteFolder, listener)) { if (!verifyOrCreateRemoteSpecialFolder(account, folder, remoteFolder, listener)) {
@ -827,15 +809,11 @@ public class MessagingController {
/* /*
* Open the remote folder. This pre-loads certain metadata like message count. * Open the remote folder. This pre-loads certain metadata like message count.
*/ */
if (K9.DEBUG) {
Timber.v("SYNC: About to open remote folder %s", folder); Timber.v("SYNC: About to open remote folder %s", folder);
}
remoteFolder.open(Folder.OPEN_MODE_RW); remoteFolder.open(Folder.OPEN_MODE_RW);
if (Expunge.EXPUNGE_ON_POLL == account.getExpungePolicy()) { if (Expunge.EXPUNGE_ON_POLL == account.getExpungePolicy()) {
if (K9.DEBUG) {
Timber.d("SYNC: Expunging folder %s:%s", account.getDescription(), folder); Timber.d("SYNC: Expunging folder %s:%s", account.getDescription(), folder);
}
remoteFolder.expunge(); remoteFolder.expunge();
} }
@ -857,9 +835,8 @@ public class MessagingController {
final List<Message> remoteMessages = new ArrayList<>(); final List<Message> remoteMessages = new ArrayList<>();
Map<String, Message> remoteUidMap = new HashMap<>(); Map<String, Message> remoteUidMap = new HashMap<>();
if (K9.DEBUG) {
Timber.v("SYNC: Remote message count for folder %s is %d", folder, remoteMessageCount); Timber.v("SYNC: Remote message count for folder %s is %d", folder, remoteMessageCount);
}
final Date earliestDate = account.getEarliestPollDate(); final Date earliestDate = account.getEarliestPollDate();
long earliestTimestamp = earliestDate != null ? earliestDate.getTime() : 0L; long earliestTimestamp = earliestDate != null ? earliestDate.getTime() : 0L;
@ -873,10 +850,8 @@ public class MessagingController {
remoteStart = 1; remoteStart = 1;
} }
if (K9.DEBUG) {
Timber.v("SYNC: About to get messages %d through %d for folder %s", Timber.v("SYNC: About to get messages %d through %d for folder %s",
remoteStart, remoteMessageCount, folder); remoteStart, remoteMessageCount, folder);
}
final AtomicInteger headerProgress = new AtomicInteger(0); final AtomicInteger headerProgress = new AtomicInteger(0);
for (MessagingListener l : getListeners(listener)) { for (MessagingListener l : getListeners(listener)) {
@ -900,9 +875,8 @@ public class MessagingController {
remoteUidMap.put(thisMess.getUid(), thisMess); remoteUidMap.put(thisMess.getUid(), thisMess);
} }
} }
if (K9.DEBUG) {
Timber.v("SYNC: Got %d messages for folder %s", remoteUidMap.size(), folder); Timber.v("SYNC: Got %d messages for folder %s", remoteUidMap.size(), folder);
}
for (MessagingListener l : getListeners(listener)) { for (MessagingListener l : getListeners(listener)) {
l.synchronizeMailboxHeadersFinished(account, folder, headerProgress.get(), remoteUidMap.size()); l.synchronizeMailboxHeadersFinished(account, folder, headerProgress.get(), remoteUidMap.size());
@ -959,13 +933,11 @@ public class MessagingController {
localFolder.setLastChecked(System.currentTimeMillis()); localFolder.setLastChecked(System.currentTimeMillis());
localFolder.setStatus(null); localFolder.setStatus(null);
if (K9.DEBUG) {
Timber.d("Done synchronizing folder %s:%s @ %tc with %d new messages", Timber.d("Done synchronizing folder %s:%s @ %tc with %d new messages",
account.getDescription(), account.getDescription(),
folder, folder,
System.currentTimeMillis(), System.currentTimeMillis(),
newMessages); newMessages);
}
for (MessagingListener l : getListeners(listener)) { for (MessagingListener l : getListeners(listener)) {
l.synchronizeMailboxFinished(account, folder, remoteMessageCount, newMessages); l.synchronizeMailboxFinished(account, folder, remoteMessageCount, newMessages);
@ -982,9 +954,7 @@ public class MessagingController {
} }
} }
if (K9.DEBUG) {
Timber.i("Done synchronizing folder %s:%s", account.getDescription(), folder); Timber.i("Done synchronizing folder %s:%s", account.getDescription(), folder);
}
} catch (AuthenticationFailedException e) { } catch (AuthenticationFailedException e) {
handleAuthenticationFailure(account, true); handleAuthenticationFailure(account, true);
@ -1065,10 +1035,8 @@ public class MessagingController {
for (MessagingListener l : getListeners(listener)) { for (MessagingListener l : getListeners(listener)) {
l.synchronizeMailboxFinished(account, folder, 0, 0); l.synchronizeMailboxFinished(account, folder, 0, 0);
} }
if (K9.DEBUG) {
Timber.i("Done synchronizing folder %s", folder);
}
Timber.i("Done synchronizing folder %s", folder);
return false; return false;
} }
} }
@ -1105,10 +1073,8 @@ public class MessagingController {
Date downloadStarted = new Date(); // now Date downloadStarted = new Date(); // now
if (earliestDate != null) { if (earliestDate != null) {
if (K9.DEBUG) {
Timber.d("Only syncing messages after %s", earliestDate); Timber.d("Only syncing messages after %s", earliestDate);
} }
}
final String folder = remoteFolder.getName(); final String folder = remoteFolder.getName();
int unreadBeforeStart = 0; int unreadBeforeStart = 0;
@ -1137,9 +1103,7 @@ public class MessagingController {
l.synchronizeMailboxProgress(account, folder, progress.get(), todo); l.synchronizeMailboxProgress(account, folder, progress.get(), todo);
} }
if (K9.DEBUG) {
Timber.d("SYNC: Have %d unsynced messages", unsyncedMessages.size()); Timber.d("SYNC: Have %d unsynced messages", unsyncedMessages.size());
}
messages.clear(); messages.clear();
final List<Message> largeMessages = new ArrayList<>(); final List<Message> largeMessages = new ArrayList<>();
@ -1164,9 +1128,7 @@ public class MessagingController {
} }
fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.ENVELOPE);
if (K9.DEBUG) {
Timber.d("SYNC: About to fetch %d unsynced messages for folder %s", unsyncedMessages.size(), folder); Timber.d("SYNC: About to fetch %d unsynced messages for folder %s", unsyncedMessages.size(), folder);
}
fetchUnsyncedMessages(account, remoteFolder, unsyncedMessages, smallMessages, largeMessages, progress, todo, fetchUnsyncedMessages(account, remoteFolder, unsyncedMessages, smallMessages, largeMessages, progress, todo,
fp); fp);
@ -1180,14 +1142,11 @@ public class MessagingController {
} }
localFolder.setPushState(updatedPushState); localFolder.setPushState(updatedPushState);
if (K9.DEBUG) {
Timber.d("SYNC: Synced unsynced messages for folder %s", folder); Timber.d("SYNC: Synced unsynced messages for folder %s", folder);
} }
}
if (K9.DEBUG) {
Timber.d("SYNC: Have %d large messages and %d small messages out of %d unsynced messages", Timber.d("SYNC: Have %d large messages and %d small messages out of %d unsynced messages",
largeMessages.size(), smallMessages.size(), unsyncedMessages.size()); largeMessages.size(), smallMessages.size(), unsyncedMessages.size());
}
unsyncedMessages.clear(); unsyncedMessages.clear();
/* /*
@ -1219,9 +1178,7 @@ public class MessagingController {
refreshLocalMessageFlags(account, remoteFolder, localFolder, syncFlagMessages, progress, todo); refreshLocalMessageFlags(account, remoteFolder, localFolder, syncFlagMessages, progress, todo);
if (K9.DEBUG) {
Timber.d("SYNC: Synced remote messages for folder %s, %d new messages", folder, newMessages.get()); Timber.d("SYNC: Synced remote messages for folder %s, %d new messages", folder, newMessages.get());
}
if (purgeToVisibleLimit) { if (purgeToVisibleLimit) {
localFolder.purgeToVisibleLimit(new MessageRemovalListener() { localFolder.purgeToVisibleLimit(new MessageRemovalListener() {
@ -1263,9 +1220,8 @@ public class MessagingController {
final List<Message> syncFlagMessages, final List<Message> syncFlagMessages,
boolean flagSyncOnly) throws MessagingException { boolean flagSyncOnly) throws MessagingException {
if (message.isSet(Flag.DELETED)) { if (message.isSet(Flag.DELETED)) {
if (K9.DEBUG) {
Timber.v("Message with uid %s is marked as deleted", message.getUid()); Timber.v("Message with uid %s is marked as deleted", message.getUid());
}
syncFlagMessages.add(message); syncFlagMessages.add(message);
return; return;
} }
@ -1275,15 +1231,11 @@ public class MessagingController {
if (localMessage == null) { if (localMessage == null) {
if (!flagSyncOnly) { if (!flagSyncOnly) {
if (!message.isSet(Flag.X_DOWNLOADED_FULL) && !message.isSet(Flag.X_DOWNLOADED_PARTIAL)) { if (!message.isSet(Flag.X_DOWNLOADED_FULL) && !message.isSet(Flag.X_DOWNLOADED_PARTIAL)) {
if (K9.DEBUG) {
Timber.v("Message with uid %s has not yet been downloaded", message.getUid()); Timber.v("Message with uid %s has not yet been downloaded", message.getUid());
}
unsyncedMessages.add(message); unsyncedMessages.add(message);
} else { } else {
if (K9.DEBUG) {
Timber.v("Message with uid %s is partially or fully downloaded", message.getUid()); Timber.v("Message with uid %s is partially or fully downloaded", message.getUid());
}
// Store the updated message locally // Store the updated message locally
localFolder.appendMessages(Collections.singletonList(message)); localFolder.appendMessages(Collections.singletonList(message));
@ -1301,14 +1253,10 @@ public class MessagingController {
} }
} }
} else if (!localMessage.isSet(Flag.DELETED)) { } else if (!localMessage.isSet(Flag.DELETED)) {
if (K9.DEBUG) {
Timber.v("Message with uid %s is present in the local store", message.getUid()); Timber.v("Message with uid %s is present in the local store", message.getUid());
}
if (!localMessage.isSet(Flag.X_DOWNLOADED_FULL) && !localMessage.isSet(Flag.X_DOWNLOADED_PARTIAL)) { if (!localMessage.isSet(Flag.X_DOWNLOADED_FULL) && !localMessage.isSet(Flag.X_DOWNLOADED_PARTIAL)) {
if (K9.DEBUG) {
Timber.v("Message with uid %s is not downloaded, even partially; trying again", message.getUid()); Timber.v("Message with uid %s is not downloaded, even partially; trying again", message.getUid());
}
unsyncedMessages.add(message); unsyncedMessages.add(message);
} else { } else {
@ -1319,11 +1267,9 @@ public class MessagingController {
syncFlagMessages.add(message); syncFlagMessages.add(message);
} }
} else { } else {
if (K9.DEBUG) {
Timber.v("Local copy of message with uid %s is marked as deleted", message.getUid()); Timber.v("Local copy of message with uid %s is marked as deleted", message.getUid());
} }
} }
}
private <T extends Message> void fetchUnsyncedMessages(final Account account, final Folder<T> remoteFolder, private <T extends Message> void fetchUnsyncedMessages(final Account account, final Folder<T> remoteFolder,
List<T> unsyncedMessages, List<T> unsyncedMessages,
@ -1386,9 +1332,7 @@ public class MessagingController {
final Date earliestDate) { final Date earliestDate) {
if (account.isSearchByDateCapable() && message.olderThan(earliestDate)) { if (account.isSearchByDateCapable() && message.olderThan(earliestDate)) {
if (K9.DEBUG) {
Timber.d("Message %s is older than %s, hence not saving", message.getUid(), earliestDate); Timber.d("Message %s is older than %s, hence not saving", message.getUid(), earliestDate);
}
return false; return false;
} }
return true; return true;
@ -1406,9 +1350,7 @@ public class MessagingController {
final Date earliestDate = account.getEarliestPollDate(); final Date earliestDate = account.getEarliestPollDate();
if (K9.DEBUG) {
Timber.d("SYNC: Fetching %d small messages for folder %s", smallMessages.size(), folder); Timber.d("SYNC: Fetching %d small messages for folder %s", smallMessages.size(), folder);
}
remoteFolder.fetch(smallMessages, remoteFolder.fetch(smallMessages,
fp, new MessageRetrievalListener<T>() { fp, new MessageRetrievalListener<T>() {
@ -1436,10 +1378,8 @@ public class MessagingController {
newMessages.incrementAndGet(); newMessages.incrementAndGet();
} }
if (K9.DEBUG) {
Timber.v("About to notify listeners that we got a new small message %s:%s:%s", Timber.v("About to notify listeners that we got a new small message %s:%s:%s",
account, folder, message.getUid()); account, folder, message.getUid());
}
// Update the listener with what we've found // Update the listener with what we've found
for (MessagingListener l : getListeners()) { for (MessagingListener l : getListeners()) {
@ -1470,10 +1410,8 @@ public class MessagingController {
} }
}); });
if (K9.DEBUG) {
Timber.d("SYNC: Done fetching small messages for folder %s", folder); Timber.d("SYNC: Done fetching small messages for folder %s", folder);
} }
}
private <T extends Message> void downloadLargeMessages(final Account account, final Folder<T> remoteFolder, private <T extends Message> void downloadLargeMessages(final Account account, final Folder<T> remoteFolder,
final LocalFolder localFolder, final LocalFolder localFolder,
@ -1485,9 +1423,9 @@ public class MessagingController {
FetchProfile fp) throws MessagingException { FetchProfile fp) throws MessagingException {
final String folder = remoteFolder.getName(); final String folder = remoteFolder.getName();
final Date earliestDate = account.getEarliestPollDate(); final Date earliestDate = account.getEarliestPollDate();
if (K9.DEBUG) {
Timber.d("SYNC: Fetching large messages for folder %s", folder); Timber.d("SYNC: Fetching large messages for folder %s", folder);
}
remoteFolder.fetch(largeMessages, fp, null); remoteFolder.fetch(largeMessages, fp, null);
for (T message : largeMessages) { for (T message : largeMessages) {
@ -1501,10 +1439,10 @@ public class MessagingController {
} else { } else {
downloadPartial(remoteFolder, localFolder, message); downloadPartial(remoteFolder, localFolder, message);
} }
if (K9.DEBUG) {
Timber.v("About to notify listeners that we got a new large message %s:%s:%s", Timber.v("About to notify listeners that we got a new large message %s:%s:%s",
account, folder, message.getUid()); account, folder, message.getUid());
}
// Update the listener with what we've found // Update the listener with what we've found
progress.incrementAndGet(); progress.incrementAndGet();
// TODO do we need to re-fetch this here? // TODO do we need to re-fetch this here?
@ -1526,10 +1464,8 @@ public class MessagingController {
notificationController.addNewMailNotification(account, localMessage, unreadBeforeStart); notificationController.addNewMailNotification(account, localMessage, unreadBeforeStart);
} }
} }
if (K9.DEBUG) {
Timber.d("SYNC: Done fetching large messages for folder %s", folder);
}
Timber.d("SYNC: Done fetching large messages for folder %s", folder);
} }
private void downloadPartial(Folder remoteFolder, LocalFolder localFolder, Message message) private void downloadPartial(Folder remoteFolder, LocalFolder localFolder, Message message)
@ -1615,10 +1551,7 @@ public class MessagingController {
final String folder = remoteFolder.getName(); final String folder = remoteFolder.getName();
if (remoteFolder.supportsFetchingFlags()) { if (remoteFolder.supportsFetchingFlags()) {
if (K9.DEBUG) { Timber.d("SYNC: About to sync flags for %d remote messages for folder %s", syncFlagMessages.size(), folder);
Timber.d("SYNC: About to sync flags for %d remote messages for folder %s",
syncFlagMessages.size(), folder);
}
FetchProfile fp = new FetchProfile(); FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.FLAGS); fp.add(FetchProfile.Item.FLAGS);
@ -1755,9 +1688,8 @@ public class MessagingController {
try { try {
for (PendingCommand command : commands) { for (PendingCommand command : commands) {
processingCommand = command; processingCommand = command;
if (K9.DEBUG) {
Timber.d("Processing pending command '%s'", command); Timber.d("Processing pending command '%s'", command);
}
for (MessagingListener l : getListeners()) { for (MessagingListener l : getListeners()) {
l.pendingCommandStarted(account, command.getCommandName()); l.pendingCommandStarted(account, command.getCommandName());
} }
@ -1770,9 +1702,8 @@ public class MessagingController {
command.execute(this, account); command.execute(this, account);
localStore.removePendingCommand(command); localStore.removePendingCommand(command);
if (K9.DEBUG) {
Timber.d("Done processing pending command '%s'", command); Timber.d("Done processing pending command '%s'", command);
}
} catch (MessagingException me) { } catch (MessagingException me) {
if (me.isPermanentFailure()) { if (me.isPermanentFailure()) {
addErrorMessage(account, null, me); addErrorMessage(account, null, me);
@ -1990,17 +1921,13 @@ public class MessagingController {
+ srcFolder + " read/write", true); + srcFolder + " read/write", true);
} }
if (K9.DEBUG) {
Timber.d("processingPendingMoveOrCopy: source folder = %s, %d messages, destination folder = %s, " + Timber.d("processingPendingMoveOrCopy: source folder = %s, %d messages, destination folder = %s, " +
"isCopy = %s", srcFolder, messages.size(), destFolder, isCopy); "isCopy = %s", srcFolder, messages.size(), destFolder, isCopy);
}
Map<String, String> remoteUidMap = null; Map<String, String> remoteUidMap = null;
if (!isCopy && destFolder.equals(account.getTrashFolderName())) { if (!isCopy && destFolder.equals(account.getTrashFolderName())) {
if (K9.DEBUG) {
Timber.d("processingPendingMoveOrCopy doing special case for deleting message"); Timber.d("processingPendingMoveOrCopy doing special case for deleting message");
}
String destFolderName = destFolder; String destFolderName = destFolder;
if (K9.FOLDER_NONE.equals(destFolderName)) { if (K9.FOLDER_NONE.equals(destFolderName)) {
@ -2017,11 +1944,7 @@ public class MessagingController {
} }
} }
if (!isCopy && Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) { if (!isCopy && Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
if (K9.DEBUG) { Timber.i("processingPendingMoveOrCopy expunging folder %s:%s", account.getDescription(), srcFolder);
Timber.i("processingPendingMoveOrCopy expunging folder %s:%s",
account.getDescription(), srcFolder);
}
remoteSrcFolder.expunge(); remoteSrcFolder.expunge();
} }
@ -2123,9 +2046,8 @@ public class MessagingController {
if (account.getErrorFolderName().equals(folder)) { if (account.getErrorFolderName().equals(folder)) {
return; return;
} }
if (K9.DEBUG) {
Timber.d("processPendingExpunge: folder = %s", folder); Timber.d("processPendingExpunge: folder = %s", folder);
}
Store remoteStore = account.getRemoteStore(); Store remoteStore = account.getRemoteStore();
Folder remoteFolder = remoteStore.getFolder(folder); Folder remoteFolder = remoteStore.getFolder(folder);
@ -2138,9 +2060,8 @@ public class MessagingController {
return; return;
} }
remoteFolder.expunge(); remoteFolder.expunge();
if (K9.DEBUG) {
Timber.d("processPendingExpunge: complete for folder = %s", folder); Timber.d("processPendingExpunge: complete for folder = %s", folder);
}
} finally { } finally {
closeFolder(remoteFolder); closeFolder(remoteFolder);
} }
@ -2263,10 +2184,8 @@ public class MessagingController {
public void markAllMessagesRead(final Account account, final String folder) { public void markAllMessagesRead(final Account account, final String folder) {
if (K9.DEBUG) {
Timber.i("Marking all messages in %s:%s as read", account.getDescription(), folder); Timber.i("Marking all messages in %s:%s as read", account.getDescription(), folder);
}
PendingCommand command = PendingMarkAllAsRead.create(folder); PendingCommand command = PendingMarkAllAsRead.create(folder);
queuePendingCommand(account, command); queuePendingCommand(account, command);
processPendingCommands(account); processPendingCommands(account);
@ -2641,9 +2560,7 @@ public class MessagingController {
l.loadAttachmentFinished(account, message, part); l.loadAttachmentFinished(account, message, part);
} }
} catch (MessagingException me) { } catch (MessagingException me) {
if (K9.DEBUG) {
Timber.v(me, "Exception loading attachment"); Timber.v(me, "Exception loading attachment");
}
for (MessagingListener l : getListeners(listener)) { for (MessagingListener l : getListeners(listener)) {
l.loadAttachmentFailed(account, message, part, me.getMessage()); l.loadAttachmentFailed(account, message, part, me.getMessage());
@ -2768,9 +2685,7 @@ public class MessagingController {
localFolder = localStore.getFolder( localFolder = localStore.getFolder(
account.getOutboxFolderName()); account.getOutboxFolderName());
if (!localFolder.exists()) { if (!localFolder.exists()) {
if (K9.DEBUG) {
Timber.v("Outbox does not exist"); Timber.v("Outbox does not exist");
}
return; return;
} }
for (MessagingListener l : getListeners()) { for (MessagingListener l : getListeners()) {
@ -2792,10 +2707,8 @@ public class MessagingController {
fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.BODY); fp.add(FetchProfile.Item.BODY);
if (K9.DEBUG) {
Timber.i("Scanning folder '%s' (%d) for messages to send", Timber.i("Scanning folder '%s' (%d) for messages to send",
account.getOutboxFolderName(), localFolder.getId()); account.getOutboxFolderName(), localFolder.getId());
}
Transport transport = transportProvider.getTransport(K9.app, account); Transport transport = transportProvider.getTransport(K9.app, account);
@ -2810,9 +2723,8 @@ public class MessagingController {
if (oldCount != null) { if (oldCount != null) {
count = oldCount; count = oldCount;
} }
if (K9.DEBUG) {
Timber.i("Send count for message %s is %d", message.getUid(), count.get()); Timber.i("Send count for message %s is %d", message.getUid(), count.get());
}
if (count.incrementAndGet() > K9.MAX_SEND_ATTEMPTS) { if (count.incrementAndGet() > K9.MAX_SEND_ATTEMPTS) {
Timber.e("Send count for message %s can't be delivered after %d attempts. " + Timber.e("Send count for message %s can't be delivered after %d attempts. " +
@ -2831,10 +2743,10 @@ public class MessagingController {
} }
message.setFlag(Flag.X_SEND_IN_PROGRESS, true); message.setFlag(Flag.X_SEND_IN_PROGRESS, true);
if (K9.DEBUG) {
Timber.i("Sending message with UID %s", message.getUid()); Timber.i("Sending message with UID %s", message.getUid());
}
transport.sendMessage(message); transport.sendMessage(message);
message.setFlag(Flag.X_SEND_IN_PROGRESS, false); message.setFlag(Flag.X_SEND_IN_PROGRESS, false);
message.setFlag(Flag.SEEN, true); message.setFlag(Flag.SEEN, true);
progress++; progress++;
@ -2889,9 +2801,8 @@ public class MessagingController {
Timber.i("Failed to send pending messages because storage is not available - trying again later."); Timber.i("Failed to send pending messages because storage is not available - trying again later.");
throw new UnavailableAccountException(e); throw new UnavailableAccountException(e);
} catch (Exception e) { } catch (Exception e) {
if (K9.DEBUG) {
Timber.v(e, "Failed to send pending messages"); Timber.v(e, "Failed to send pending messages");
}
for (MessagingListener l : getListeners()) { for (MessagingListener l : getListeners()) {
l.sendPendingMessagesFailed(account); l.sendPendingMessagesFailed(account);
} }
@ -2908,23 +2819,15 @@ public class MessagingController {
private void moveOrDeleteSentMessage(Account account, LocalStore localStore, private void moveOrDeleteSentMessage(Account account, LocalStore localStore,
LocalFolder localFolder, LocalMessage message) throws MessagingException { LocalFolder localFolder, LocalMessage message) throws MessagingException {
if (!account.hasSentFolder()) { if (!account.hasSentFolder()) {
if (K9.DEBUG) {
Timber.i("Account does not have a sent mail folder; deleting sent message"); Timber.i("Account does not have a sent mail folder; deleting sent message");
}
message.setFlag(Flag.DELETED, true); message.setFlag(Flag.DELETED, true);
} else { } else {
LocalFolder localSentFolder = localStore.getFolder(account.getSentFolderName()); LocalFolder localSentFolder = localStore.getFolder(account.getSentFolderName());
if (K9.DEBUG) { Timber.i("Moving sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getId());
Timber.i("Moving sent message to folder '%s' (%d)",
account.getSentFolderName(), localSentFolder.getId());
}
localFolder.moveMessages(Collections.singletonList(message), localSentFolder); localFolder.moveMessages(Collections.singletonList(message), localSentFolder);
if (K9.DEBUG) { Timber.i("Moved sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getId());
Timber.i("Moved sent message to folder '%s' (%d)",
account.getSentFolderName(), localSentFolder.getId());
}
PendingCommand command = PendingAppend.create(localSentFolder.getName(), message.getUid()); PendingCommand command = PendingAppend.create(localSentFolder.getName(), message.getUid());
queuePendingCommand(account, command); queuePendingCommand(account, command);
@ -3233,10 +3136,8 @@ public class MessagingController {
origUidMap.put(message.getUid(), message); origUidMap.put(message.getUid(), message);
} }
if (K9.DEBUG) { Timber.i("moveOrCopyMessageSynchronous: source folder = %s, %d messages, destination folder = %s, " +
Timber.i("moveOrCopyMessageSynchronous: source folder = %s, %d messages, " + "isCopy = %s", srcFolder, messages.size(), destFolder, isCopy);
"destination folder = %s, isCopy = %s", srcFolder, messages.size(), destFolder, isCopy);
}
Map<String, String> uidMap; Map<String, String> uidMap;
@ -3438,9 +3339,7 @@ public class MessagingController {
localFolder = localStore.getFolder(folder); localFolder = localStore.getFolder(folder);
Map<String, String> uidMap = null; Map<String, String> uidMap = null;
if (folder.equals(account.getTrashFolderName()) || !account.hasTrashFolder()) { if (folder.equals(account.getTrashFolderName()) || !account.hasTrashFolder()) {
if (K9.DEBUG) {
Timber.d("Deleting messages in trash folder or trash set to -None-, not copying"); Timber.d("Deleting messages in trash folder or trash set to -None-, not copying");
}
localFolder.setFlags(messages, Collections.singleton(Flag.DELETED), true); localFolder.setFlags(messages, Collections.singleton(Flag.DELETED), true);
} else { } else {
@ -3449,9 +3348,7 @@ public class MessagingController {
localTrashFolder.create(Folder.FolderType.HOLDS_MESSAGES); localTrashFolder.create(Folder.FolderType.HOLDS_MESSAGES);
} }
if (localTrashFolder.exists()) { if (localTrashFolder.exists()) {
if (K9.DEBUG) {
Timber.d("Deleting messages in normal folder, moving"); Timber.d("Deleting messages in normal folder, moving");
}
uidMap = localFolder.moveMessages(messages, localTrashFolder); uidMap = localFolder.moveMessages(messages, localTrashFolder);
@ -3466,9 +3363,7 @@ public class MessagingController {
} }
} }
if (K9.DEBUG) {
Timber.d("Delete policy for account %s is %s", account.getDescription(), account.getDeletePolicy()); Timber.d("Delete policy for account %s is %s", account.getDescription(), account.getDeletePolicy());
}
if (folder.equals(account.getOutboxFolderName())) { if (folder.equals(account.getOutboxFolderName())) {
for (Message message : messages) { for (Message message : messages) {
@ -3489,10 +3384,8 @@ public class MessagingController {
queueSetFlag(account, folder, true, Flag.SEEN, uids); queueSetFlag(account, folder, true, Flag.SEEN, uids);
processPendingCommands(account); processPendingCommands(account);
} else { } else {
if (K9.DEBUG) {
Timber.d("Delete policy %s prevents delete from server", account.getDeletePolicy()); Timber.d("Delete policy %s prevents delete from server", account.getDeletePolicy());
} }
}
unsuppressMessages(account, messages); unsuppressMessages(account, messages);
} catch (UnavailableStorageException e) { } catch (UnavailableStorageException e) {
@ -3629,10 +3522,8 @@ public class MessagingController {
} }
public void sendAlternate(Context context, Account account, LocalMessage message) { public void sendAlternate(Context context, Account account, LocalMessage message) {
if (K9.DEBUG) {
Timber.d("Got message %s:%s:%s for sendAlternate", Timber.d("Got message %s:%s:%s for sendAlternate",
account.getDescription(), message.getFolder(), message.getUid()); account.getDescription(), message.getFolder(), message.getUid());
}
Intent msg = new Intent(Intent.ACTION_SEND); Intent msg = new Intent(Intent.ACTION_SEND);
String quotedText = null; String quotedText = null;
@ -3700,9 +3591,8 @@ public class MessagingController {
public void run() { public void run() {
try { try {
if (K9.DEBUG) {
Timber.i("Starting mail check"); Timber.i("Starting mail check");
}
Preferences prefs = Preferences.getPreferences(context); Preferences prefs = Preferences.getPreferences(context);
Collection<Account> accounts; Collection<Account> accounts;
@ -3725,9 +3615,7 @@ public class MessagingController {
@Override @Override
public void run() { public void run() {
if (K9.DEBUG) {
Timber.i("Finished mail sync"); Timber.i("Finished mail sync");
}
if (wakeLock != null) { if (wakeLock != null) {
wakeLock.release(); wakeLock.release();
@ -3748,22 +3636,16 @@ public class MessagingController {
final boolean ignoreLastCheckedTime, final boolean ignoreLastCheckedTime,
final MessagingListener listener) { final MessagingListener listener) {
if (!account.isAvailable(context)) { if (!account.isAvailable(context)) {
if (K9.DEBUG) {
Timber.i("Skipping synchronizing unavailable account %s", account.getDescription()); Timber.i("Skipping synchronizing unavailable account %s", account.getDescription());
}
return; return;
} }
final long accountInterval = account.getAutomaticCheckIntervalMinutes() * 60 * 1000; final long accountInterval = account.getAutomaticCheckIntervalMinutes() * 60 * 1000;
if (!ignoreLastCheckedTime && accountInterval <= 0) { if (!ignoreLastCheckedTime && accountInterval <= 0) {
if (K9.DEBUG) {
Timber.i("Skipping synchronizing account %s", account.getDescription()); Timber.i("Skipping synchronizing account %s", account.getDescription());
}
return; return;
} }
if (K9.DEBUG) {
Timber.i("Synchronizing account %s", account.getDescription()); Timber.i("Synchronizing account %s", account.getDescription());
}
account.setRingNotified(false); account.setRingNotified(false);
@ -3812,9 +3694,8 @@ public class MessagingController {
putBackground("clear notification flag for " + account.getDescription(), null, new Runnable() { putBackground("clear notification flag for " + account.getDescription(), null, new Runnable() {
@Override @Override
public void run() { public void run() {
if (K9.DEBUG) {
Timber.v("Clearing notification flag for %s", account.getDescription()); Timber.v("Clearing notification flag for %s", account.getDescription());
}
account.setRingNotified(false); account.setRingNotified(false);
try { try {
AccountStats stats = account.getStats(context); AccountStats stats = account.getStats(context);
@ -3840,20 +3721,14 @@ public class MessagingController {
final long accountInterval, final long accountInterval,
final MessagingListener listener) { final MessagingListener listener) {
if (K9.DEBUG) {
Timber.v("Folder %s was last synced @ %tc", folder.getName(), folder.getLastChecked()); Timber.v("Folder %s was last synced @ %tc", folder.getName(), folder.getLastChecked());
}
if (!ignoreLastCheckedTime && folder.getLastChecked() > if (!ignoreLastCheckedTime && folder.getLastChecked() > System.currentTimeMillis() - accountInterval) {
(System.currentTimeMillis() - accountInterval)) {
if (K9.DEBUG) {
Timber.v("Not syncing folder %s, previously synced @ %tc which would be too recent for the account " + Timber.v("Not syncing folder %s, previously synced @ %tc which would be too recent for the account " +
"period", folder.getName(), folder.getLastChecked()); "period", folder.getName(), folder.getLastChecked());
}
return; return;
} }
putBackground("sync" + folder.getName(), null, new Runnable() { putBackground("sync" + folder.getName(), null, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -3867,11 +3742,9 @@ public class MessagingController {
if (!ignoreLastCheckedTime && tLocalFolder.getLastChecked() > if (!ignoreLastCheckedTime && tLocalFolder.getLastChecked() >
(System.currentTimeMillis() - accountInterval)) { (System.currentTimeMillis() - accountInterval)) {
if (K9.DEBUG) {
Timber.v("Not running Command for folder %s, previously synced @ %tc which would " + Timber.v("Not running Command for folder %s, previously synced @ %tc which would " +
"be too recent for the account period", "be too recent for the account period",
folder.getName(), folder.getLastChecked()); folder.getName(), folder.getLastChecked());
}
return; return;
} }
showFetchingMailNotificationIfNecessary(account, folder); showFetchingMailNotificationIfNecessary(account, folder);
@ -3881,7 +3754,6 @@ public class MessagingController {
clearFetchingMailNotificationIfNecessary(account); clearFetchingMailNotificationIfNecessary(account);
} }
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "Exception while processing folder %s:%s", Timber.e(e, "Exception while processing folder %s:%s",
account.getDescription(), folder.getName()); account.getDescription(), folder.getName());
addErrorMessage(account, null, e); addErrorMessage(account, null, e);
@ -4040,10 +3912,8 @@ public class MessagingController {
try { try {
Integer messageUid = Integer.parseInt(message.getUid()); Integer messageUid = Integer.parseInt(message.getUid());
if (messageUid <= localFolder.getLastUid()) { if (messageUid <= localFolder.getLastUid()) {
if (K9.DEBUG) {
Timber.d("Message uid is %s, max message uid is %s. Skipping notification.", Timber.d("Message uid is %s, max message uid is %s. Skipping notification.",
messageUid, localFolder.getLastUid()); messageUid, localFolder.getLastUid());
}
return false; return false;
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -4230,9 +4100,8 @@ public class MessagingController {
continue; continue;
} }
if (K9.DEBUG) {
Timber.i("Starting pusher for %s:%s", account.getDescription(), folder.getName()); Timber.i("Starting pusher for %s:%s", account.getDescription(), folder.getName());
}
names.add(folder.getName()); names.add(folder.getName());
} }
@ -4242,10 +4111,8 @@ public class MessagingController {
int maxPushFolders = account.getMaxPushFolders(); int maxPushFolders = account.getMaxPushFolders();
if (names.size() > maxPushFolders) { if (names.size() > maxPushFolders) {
if (K9.DEBUG) {
Timber.i("Count of folders to push for account %s is %d, greater than limit of %d, truncating", Timber.i("Count of folders to push for account %s is %d, greater than limit of %d, truncating",
account.getDescription(), names.size(), maxPushFolders); account.getDescription(), names.size(), maxPushFolders);
}
names = names.subList(0, maxPushFolders); names = names.subList(0, maxPushFolders);
} }
@ -4253,9 +4120,7 @@ public class MessagingController {
try { try {
Store store = account.getRemoteStore(); Store store = account.getRemoteStore();
if (!store.isPushCapable()) { if (!store.isPushCapable()) {
if (K9.DEBUG) {
Timber.i("Account %s is not push capable, skipping", account.getDescription()); Timber.i("Account %s is not push capable, skipping", account.getDescription());
}
return false; return false;
} }
@ -4273,9 +4138,7 @@ public class MessagingController {
return true; return true;
} else { } else {
if (K9.DEBUG) {
Timber.i("No folders are configured for pushing in account %s", account.getDescription()); Timber.i("No folders are configured for pushing in account %s", account.getDescription());
}
return false; return false;
} }
@ -4286,9 +4149,7 @@ public class MessagingController {
} }
public void stopAllPushing() { public void stopAllPushing() {
if (K9.DEBUG) {
Timber.i("Stopping all pushers"); Timber.i("Stopping all pushers");
}
Iterator<Pusher> iter = pushers.values().iterator(); Iterator<Pusher> iter = pushers.values().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -4300,10 +4161,8 @@ public class MessagingController {
public void messagesArrived(final Account account, final Folder remoteFolder, final List<Message> messages, public void messagesArrived(final Account account, final Folder remoteFolder, final List<Message> messages,
final boolean flagSyncOnly) { final boolean flagSyncOnly) {
if (K9.DEBUG) {
Timber.i("Got new pushed email messages for account %s, folder %s", Timber.i("Got new pushed email messages for account %s, folder %s",
account.getDescription(), remoteFolder.getName()); account.getDescription(), remoteFolder.getName());
}
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
putBackground("Push messageArrived of account " + account.getDescription() putBackground("Push messageArrived of account " + account.getDescription()
@ -4324,9 +4183,7 @@ public class MessagingController {
localFolder.setLastPush(System.currentTimeMillis()); localFolder.setLastPush(System.currentTimeMillis());
localFolder.setStatus(null); localFolder.setStatus(null);
if (K9.DEBUG) {
Timber.i("messagesArrived newCount = %d, unread count = %d", newCount, unreadMessageCount); Timber.i("messagesArrived newCount = %d, unread count = %d", newCount, unreadMessageCount);
}
if (unreadMessageCount == 0) { if (unreadMessageCount == 0) {
notificationController.clearNewMailNotifications(account); notificationController.clearNewMailNotifications(account);
@ -4360,10 +4217,9 @@ public class MessagingController {
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "Interrupted while awaiting latch release"); Timber.e(e, "Interrupted while awaiting latch release");
} }
if (K9.DEBUG) {
Timber.i("MessagingController.messagesArrivedLatch released"); Timber.i("MessagingController.messagesArrivedLatch released");
} }
}
public void systemStatusChanged() { public void systemStatusChanged() {
for (MessagingListener l : getListeners()) { for (MessagingListener l : getListeners()) {

View file

@ -40,8 +40,8 @@ public class MessagingControllerPushReceiver implements PushReceiver {
} }
public void syncFolder(Folder folder) { public void syncFolder(Folder folder) {
if (K9.DEBUG)
Timber.v("syncFolder(%s)", folder.getName()); Timber.v("syncFolder(%s)", folder.getName());
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
controller.synchronizeMailbox(account, folder.getName(), new SimpleMessagingListener() { controller.synchronizeMailbox(account, folder.getName(), new SimpleMessagingListener() {
@Override @Override
@ -57,11 +57,10 @@ public class MessagingControllerPushReceiver implements PushReceiver {
} }
}, folder); }, folder);
if (K9.DEBUG)
Timber.v("syncFolder(%s) about to await latch release", folder.getName()); Timber.v("syncFolder(%s) about to await latch release", folder.getName());
try { try {
latch.await(); latch.await();
if (K9.DEBUG)
Timber.v("syncFolder(%s) got latch release", folder.getName()); Timber.v("syncFolder(%s) got latch release", folder.getName());
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "Interrupted while awaiting latch release"); Timber.e(e, "Interrupted while awaiting latch release");

View file

@ -108,7 +108,6 @@ public class ConfirmationDialogFragment extends DialogFragment implements OnClic
try { try {
mListener = (ConfirmationDialogFragmentListener) activity; mListener = (ConfirmationDialogFragmentListener) activity;
} catch (ClassCastException e) { } catch (ClassCastException e) {
if (K9.DEBUG)
Timber.d("%s did not implement ConfirmationDialogFragmentListener", activity); Timber.d("%s did not implement ConfirmationDialogFragmentListener", activity);
} }
} }

View file

@ -381,15 +381,12 @@ public class Utility {
while (imgMatches.find()) { while (imgMatches.find()) {
String uriScheme = imgMatches.group(1); String uriScheme = imgMatches.group(1);
if (uriScheme.equals("http") || uriScheme.equals("https")) { if (uriScheme.equals("http") || uriScheme.equals("https")) {
if (K9.DEBUG) {
Timber.d("External images found"); Timber.d("External images found");
}
return true; return true;
} }
} }
if (K9.DEBUG) {
Timber.d("No external images."); Timber.d("No external images.");
}
return false; return false;
} }

View file

@ -1036,14 +1036,12 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
String oldUID = message.getUid(); String oldUID = message.getUid();
if (K9.DEBUG) {
Timber.d("Updating folder_id to %s for message with UID %s, " + Timber.d("Updating folder_id to %s for message with UID %s, " +
"id %d currently in folder %s", "id %d currently in folder %s",
lDestFolder.getId(), lDestFolder.getId(),
message.getUid(), message.getUid(),
lMessage.getId(), lMessage.getId(),
getName()); getName());
}
String newUid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString(); String newUid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
message.setUid(newUid); message.setUid(newUid);
@ -1935,7 +1933,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
return null; return null;
} }
}); });
if (K9.DEBUG)
Timber.d("Updated last UID for folder %s to %s", mName, lastUid); Timber.d("Updated last UID for folder %s to %s", mName, lastUid);
mLastUid = lastUid; mLastUid = lastUid;
} }

View file

@ -301,8 +301,9 @@ public class LocalStore extends Store implements Serializable {
} }
public void compact() throws MessagingException { public void compact() throws MessagingException {
if (K9.DEBUG) if (K9.DEBUG) {
Timber.i("Before compaction size = %d", getSize()); Timber.i("Before compaction size = %d", getSize());
}
database.execute(false, new DbCallback<Void>() { database.execute(false, new DbCallback<Void>() {
@Override @Override
@ -311,22 +312,24 @@ public class LocalStore extends Store implements Serializable {
return null; return null;
} }
}); });
if (K9.DEBUG)
if (K9.DEBUG) {
Timber.i("After compaction size = %d", getSize()); Timber.i("After compaction size = %d", getSize());
} }
}
public void clear() throws MessagingException { public void clear() throws MessagingException {
if (K9.DEBUG) if (K9.DEBUG) {
Timber.i("Before prune size = %d", getSize()); Timber.i("Before prune size = %d", getSize());
}
deleteAllMessageDataFromDisk(); deleteAllMessageDataFromDisk();
if (K9.DEBUG) { if (K9.DEBUG) {
Timber.i("After prune / before compaction size = %d", getSize()); Timber.i("After prune / before compaction size = %d", getSize());
Timber.i("Before clear folder count = %d", getFolderCount()); Timber.i("Before clear folder count = %d", getFolderCount());
Timber.i("Before clear message count = %d", getMessageCount()); Timber.i("Before clear message count = %d", getMessageCount());
Timber.i("After prune / before clear size = %d", getSize()); Timber.i("After prune / before clear size = %d", getSize());
} }
@ -351,7 +354,6 @@ public class LocalStore extends Store implements Serializable {
if (K9.DEBUG) { if (K9.DEBUG) {
Timber.i("After clear message count = %d", getMessageCount()); Timber.i("After clear message count = %d", getMessageCount());
Timber.i("After clear size = %d", getSize()); Timber.i("After clear size = %d", getSize());
} }
} }
@ -582,9 +584,7 @@ public class LocalStore extends Store implements Serializable {
((!TextUtils.isEmpty(where)) ? " AND (" + where + ")" : "") + ((!TextUtils.isEmpty(where)) ? " AND (" + where + ")" : "") +
" ORDER BY date DESC"; " ORDER BY date DESC";
if (K9.DEBUG) {
Timber.d("Query = %s", sqlQuery); Timber.d("Query = %s", sqlQuery);
}
return getMessages(retrievalListener, null, sqlQuery, selectionArgs); return getMessages(retrievalListener, null, sqlQuery, selectionArgs);
} }

View file

@ -75,10 +75,7 @@ public class LockableDatabase {
return; return;
} }
if (K9.DEBUG) { Timber.d("LockableDatabase: Closing DB %s due to unmount event on StorageProvider: %s", uUid, providerId);
Timber.d("LockableDatabase: Closing DB %s due to unmount event on StorageProvider: %s",
uUid, providerId);
}
try { try {
lockWrite(); lockWrite();
@ -98,10 +95,7 @@ public class LockableDatabase {
return; return;
} }
if (K9.DEBUG) { Timber.d("LockableDatabase: Opening DB %s due to mount event on StorageProvider: %s", uUid, providerId);
Timber.d("LockableDatabase: Opening DB %s due to mount event on StorageProvider: %s",
uUid, providerId);
}
try { try {
openOrCreateDataspace(); openOrCreateDataspace();
@ -465,7 +459,6 @@ public class LockableDatabase {
try { try {
mDb.close(); mDb.close();
} catch (Exception e) { } catch (Exception e) {
if (K9.DEBUG)
Timber.d("Exception caught in DB close: %s", e.getMessage()); Timber.d("Exception caught in DB close: %s", e.getMessage());
} }
final StorageManager storageManager = getStorageManager(); final StorageManager storageManager = getStorageManager();
@ -475,19 +468,18 @@ public class LockableDatabase {
for (File attachment : attachments) { for (File attachment : attachments) {
if (attachment.exists()) { if (attachment.exists()) {
boolean attachmentWasDeleted = attachment.delete(); boolean attachmentWasDeleted = attachment.delete();
if (!attachmentWasDeleted && K9.DEBUG) { if (!attachmentWasDeleted) {
Timber.d("Attachment was not deleted!"); Timber.d("Attachment was not deleted!");
} }
} }
} }
if (attachmentDirectory.exists()) { if (attachmentDirectory.exists()) {
boolean attachmentDirectoryWasDeleted = attachmentDirectory.delete(); boolean attachmentDirectoryWasDeleted = attachmentDirectory.delete();
if (!attachmentDirectoryWasDeleted && K9.DEBUG) { if (!attachmentDirectoryWasDeleted) {
Timber.d("Attachment directory was not deleted!"); Timber.d("Attachment directory was not deleted!");
} }
} }
} catch (Exception e) { } catch (Exception e) {
if (K9.DEBUG)
Timber.d("Exception caught in clearing attachments: %s", e.getMessage()); Timber.d("Exception caught in clearing attachments: %s", e.getMessage());
} }
try { try {

View file

@ -450,14 +450,13 @@ class MigrationTo51 {
private static MimeStructureState insertMimeAttachmentPart(SQLiteDatabase db, File attachmentDirOld, private static MimeStructureState insertMimeAttachmentPart(SQLiteDatabase db, File attachmentDirOld,
File attachmentDirNew, MimeStructureState structureState, long id, int size, String name, String mimeType, File attachmentDirNew, MimeStructureState structureState, long id, int size, String name, String mimeType,
String storeData, String contentUriString, String contentId, String contentDisposition) { String storeData, String contentUriString, String contentId, String contentDisposition) {
if (K9.DEBUG) {
Timber.d("processing attachment %d, %s, %s, %s, %s", Timber.d("processing attachment %d, %s, %s, %s, %s",
id, id,
name, name,
mimeType, mimeType,
storeData, storeData,
contentUriString); contentUriString);
}
if (contentDisposition == null) { if (contentDisposition == null) {
contentDisposition = "attachment"; contentDisposition = "attachment";
@ -501,7 +500,7 @@ class MigrationTo51 {
} else { } else {
attachmentFileToMove = null; attachmentFileToMove = null;
} }
if (K9.DEBUG && attachmentFileToMove == null) { if (attachmentFileToMove == null) {
Timber.d("matching attachment is in local cache"); Timber.d("matching attachment is in local cache");
} }

View file

@ -97,10 +97,7 @@ public class IdentityHeaderBuilder {
String k9identity = IdentityField.IDENTITY_VERSION_1 + uri.build().getEncodedQuery(); String k9identity = IdentityField.IDENTITY_VERSION_1 + uri.build().getEncodedQuery();
if (K9.DEBUG) {
Timber.d("Generated identity: %s", k9identity); Timber.d("Generated identity: %s", k9identity);
}
return k9identity; return k9identity;
} }

View file

@ -24,9 +24,7 @@ public class IdentityHeaderParser {
public static Map<IdentityField, String> parse(final String identityString) { public static Map<IdentityField, String> parse(final String identityString) {
Map<IdentityField, String> identity = new HashMap<IdentityField, String>(); Map<IdentityField, String> identity = new HashMap<IdentityField, String>();
if (K9.DEBUG) {
Timber.d("Decoding identity: %s", identityString); Timber.d("Decoding identity: %s", identityString);
}
if (identityString == null || identityString.length() < 1) { if (identityString == null || identityString.length() < 1) {
return identity; return identity;
@ -44,9 +42,7 @@ public class IdentityHeaderParser {
} }
} }
if (K9.DEBUG) { Timber.d("Decoded identity: %s", identity);
Timber.d("Decoded identity: %s", identity.toString());
}
// Sanity check our Integers so that recipients of this result don't have to. // Sanity check our Integers so that recipients of this result don't have to.
for (IdentityField key : IdentityField.getIntegerFields()) { for (IdentityField key : IdentityField.getIntegerFields()) {
@ -61,9 +57,8 @@ public class IdentityHeaderParser {
} else { } else {
// Legacy identity // Legacy identity
if (K9.DEBUG) {
Timber.d("Got a saved legacy identity: %s", identityString); Timber.d("Got a saved legacy identity: %s", identityString);
}
StringTokenizer tokenizer = new StringTokenizer(identityString, ":", false); StringTokenizer tokenizer = new StringTokenizer(identityString, ":", false);
// First item is the body length. We use this to separate the composed reply from the quoted text. // First item is the body length. We use this to separate the composed reply from the quoted text.

View file

@ -22,17 +22,13 @@ public class BodyTextExtractor {
// HTML takes precedence, then text. // HTML takes precedence, then text.
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/html"); part = MimeUtility.findFirstPartByMimeType(messagePart, "text/html");
if (part != null) { if (part != null) {
if (K9.DEBUG) {
Timber.d("getBodyTextFromMessage: HTML requested, HTML found."); Timber.d("getBodyTextFromMessage: HTML requested, HTML found.");
}
return MessageExtractor.getTextFromPart(part); return MessageExtractor.getTextFromPart(part);
} }
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/plain"); part = MimeUtility.findFirstPartByMimeType(messagePart, "text/plain");
if (part != null) { if (part != null) {
if (K9.DEBUG) {
Timber.d("getBodyTextFromMessage: HTML requested, text found."); Timber.d("getBodyTextFromMessage: HTML requested, text found.");
}
String text = MessageExtractor.getTextFromPart(part); String text = MessageExtractor.getTextFromPart(part);
return HtmlConverter.textToHtml(text); return HtmlConverter.textToHtml(text);
} }
@ -40,17 +36,13 @@ public class BodyTextExtractor {
// Text takes precedence, then html. // Text takes precedence, then html.
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/plain"); part = MimeUtility.findFirstPartByMimeType(messagePart, "text/plain");
if (part != null) { if (part != null) {
if (K9.DEBUG) {
Timber.d("getBodyTextFromMessage: Text requested, text found."); Timber.d("getBodyTextFromMessage: Text requested, text found.");
}
return MessageExtractor.getTextFromPart(part); return MessageExtractor.getTextFromPart(part);
} }
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/html"); part = MimeUtility.findFirstPartByMimeType(messagePart, "text/html");
if (part != null) { if (part != null) {
if (K9.DEBUG) {
Timber.d("getBodyTextFromMessage: Text requested, HTML found."); Timber.d("getBodyTextFromMessage: Text requested, HTML found.");
}
String text = MessageExtractor.getTextFromPart(part); String text = MessageExtractor.getTextFromPart(part);
return HtmlConverter.htmlToText(text); return HtmlConverter.htmlToText(text);
} }

View file

@ -149,9 +149,7 @@ public class HtmlQuoteCreator {
hasBodyTag = true; hasBodyTag = true;
} }
if (K9.DEBUG) {
Timber.d("Open: hasHtmlTag:%s hasHeadTag:%s hasBodyTag:%s", hasHtmlTag, hasHeadTag, hasBodyTag); Timber.d("Open: hasHtmlTag:%s hasHeadTag:%s hasBodyTag:%s", hasHtmlTag, hasHeadTag, hasBodyTag);
}
// Given our inspections, let's figure out where to start our content. // Given our inspections, let's figure out where to start our content.
// This is the ideal case -- there's a BODY tag and we insert ourselves just after it. // This is the ideal case -- there's a BODY tag and we insert ourselves just after it.
@ -202,9 +200,7 @@ public class HtmlQuoteCreator {
hasBodyEndTag = true; hasBodyEndTag = true;
} }
if (K9.DEBUG) {
Timber.d("Close: hasHtmlEndTag:%s hasBodyEndTag:%s", hasHtmlEndTag, hasBodyEndTag); Timber.d("Close: hasHtmlEndTag:%s hasBodyEndTag:%s", hasHtmlEndTag, hasBodyEndTag);
}
// Now figure out where to put our footer. // Now figure out where to put our footer.
// This is the ideal case -- there's a BODY tag and we insert ourselves just before it. // This is the ideal case -- there's a BODY tag and we insert ourselves just before it.

View file

@ -122,9 +122,7 @@ public class NotificationActionService extends CoreService {
@Override @Override
public int startService(Intent intent, int startId) { public int startService(Intent intent, int startId) {
if (K9.DEBUG) {
Timber.i("NotificationActionService started with startId = %d", startId); Timber.i("NotificationActionService started with startId = %d", startId);
}
String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT_UUID); String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT_UUID);
Preferences preferences = Preferences.getPreferences(this); Preferences preferences = Preferences.getPreferences(this);
@ -147,10 +145,8 @@ public class NotificationActionService extends CoreService {
} else if (ACTION_SPAM.equals(action)) { } else if (ACTION_SPAM.equals(action)) {
markMessageAsSpam(intent, account, controller); markMessageAsSpam(intent, account, controller);
} else if (ACTION_DISMISS.equals(action)) { } else if (ACTION_DISMISS.equals(action)) {
if (K9.DEBUG) {
Timber.i("Notification dismissed"); Timber.i("Notification dismissed");
} }
}
cancelNotifications(intent, account, controller); cancelNotifications(intent, account, controller);
@ -158,9 +154,7 @@ public class NotificationActionService extends CoreService {
} }
private void markMessagesAsRead(Intent intent, Account account, MessagingController controller) { private void markMessagesAsRead(Intent intent, Account account, MessagingController controller) {
if (K9.DEBUG) {
Timber.i("NotificationActionService marking messages as read"); Timber.i("NotificationActionService marking messages as read");
}
List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES); List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES);
List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings); List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
@ -172,9 +166,7 @@ public class NotificationActionService extends CoreService {
} }
private void deleteMessages(Intent intent, MessagingController controller) { private void deleteMessages(Intent intent, MessagingController controller) {
if (K9.DEBUG) {
Timber.i("NotificationActionService deleting messages"); Timber.i("NotificationActionService deleting messages");
}
List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES); List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES);
List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings); List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
@ -182,9 +174,7 @@ public class NotificationActionService extends CoreService {
} }
private void archiveMessages(Intent intent, Account account, MessagingController controller) { private void archiveMessages(Intent intent, Account account, MessagingController controller) {
if (K9.DEBUG) {
Timber.i("NotificationActionService archiving messages"); Timber.i("NotificationActionService archiving messages");
}
String archiveFolderName = account.getArchiveFolderName(); String archiveFolderName = account.getArchiveFolderName();
if (archiveFolderName == null || if (archiveFolderName == null ||
@ -205,9 +195,7 @@ public class NotificationActionService extends CoreService {
} }
private void markMessageAsSpam(Intent intent, Account account, MessagingController controller) { private void markMessageAsSpam(Intent intent, Account account, MessagingController controller) {
if (K9.DEBUG) {
Timber.i("NotificationActionService moving messages to spam"); Timber.i("NotificationActionService moving messages to spam");
}
String messageReferenceString = intent.getStringExtra(EXTRA_MESSAGE_REFERENCE); String messageReferenceString = intent.getStringExtra(EXTRA_MESSAGE_REFERENCE);
MessageReference messageReference = MessageReference.parse(messageReferenceString); MessageReference messageReference = MessageReference.parse(messageReferenceString);

View file

@ -177,10 +177,8 @@ public class Settings {
validatedSettingsMutable.remove(settingName); validatedSettingsMutable.remove(settingName);
deletedSettingsMutable.add(settingName); deletedSettingsMutable.add(settingName);
if (K9.DEBUG) {
Timber.v("Removed setting \"%s\"", settingName); Timber.v("Removed setting \"%s\"", settingName);
} }
}
/** /**
* Convert settings from the internal representation to the string representation used in the * Convert settings from the internal representation to the string representation used in the
@ -211,11 +209,9 @@ public class Settings {
serializedSettings.put(settingName, stringValue); serializedSettings.put(settingName, stringValue);
} else { } else {
if (K9.DEBUG) {
Timber.w("Settings.convert() called with a setting that should have been removed: %s", settingName); Timber.w("Settings.convert() called with a setting that should have been removed: %s", settingName);
} }
} }
}
return serializedSettings; return serializedSettings;
} }

View file

@ -187,10 +187,7 @@ public class SettingsExporter {
"This shouldn't happen!", key, valueString); "This shouldn't happen!", key, valueString);
} }
} else { } else {
if (K9.DEBUG) {
Timber.d("Couldn't find key \"%s\" in preference storage. Using default value.", key); Timber.d("Couldn't find key \"%s\" in preference storage. Using default value.", key);
}
writeKeyAndDefaultValueFromSetting(serializer, key, setting); writeKeyAndDefaultValueFromSetting(serializer, key, setting);
} }
} }

View file

@ -183,15 +183,11 @@ public class SettingsImporter {
Timber.w("Was asked to import global settings but none found."); Timber.w("Was asked to import global settings but none found.");
} }
if (editor.commit()) { if (editor.commit()) {
if (K9.DEBUG) {
Timber.v("Committed global settings to the preference storage."); Timber.v("Committed global settings to the preference storage.");
}
globalSettingsImported = true; globalSettingsImported = true;
} else { } else {
if (K9.DEBUG) {
Timber.v("Failed to commit global settings to the preference storage"); Timber.v("Failed to commit global settings to the preference storage");
} }
}
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "Exception while importing global settings"); Timber.e(e, "Exception while importing global settings");
} }
@ -209,10 +205,8 @@ public class SettingsImporter {
imported.contentVersion, account, overwrite); imported.contentVersion, account, overwrite);
if (editor.commit()) { if (editor.commit()) {
if (K9.DEBUG) {
Timber.v("Committed settings for account \"%s\" to the settings database.", Timber.v("Committed settings for account \"%s\" to the settings database.",
importResult.imported.name); importResult.imported.name);
}
// Add UUID of the account we just imported to the list of // Add UUID of the account we just imported to the list of
// account UUIDs // account UUIDs
@ -236,17 +230,15 @@ public class SettingsImporter {
importedAccounts.add(importResult); importedAccounts.add(importResult);
} else { } else {
if (K9.DEBUG) {
Timber.w("Error while committing settings for account \"%s\" to the settings " + Timber.w("Error while committing settings for account \"%s\" to the settings " +
"database.", importResult.original.name); "database.", importResult.original.name);
}
erroneousAccounts.add(importResult.original); erroneousAccounts.add(importResult.original);
} }
} catch (InvalidSettingValueException e) { } catch (InvalidSettingValueException e) {
if (K9.DEBUG) {
Timber.e(e, "Encountered invalid setting while importing account \"%s\"", Timber.e(e, "Encountered invalid setting while importing account \"%s\"",
account.name); account.name);
}
erroneousAccounts.add(new AccountDescription(account.name, account.uuid)); erroneousAccounts.add(new AccountDescription(account.name, account.uuid));
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "Exception while importing account \"%s\"", account.name); Timber.e(e, "Exception while importing account \"%s\"", account.name);

View file

@ -141,25 +141,17 @@ public class Storage {
public static Storage getStorage(Context context) { public static Storage getStorage(Context context) {
Storage tmpStorage = storages.get(context); Storage tmpStorage = storages.get(context);
if (tmpStorage != null) { if (tmpStorage != null) {
if (K9.DEBUG) {
Timber.d("Returning already existing Storage"); Timber.d("Returning already existing Storage");
}
return tmpStorage; return tmpStorage;
} else { } else {
if (K9.DEBUG) {
Timber.d("Creating provisional storage"); Timber.d("Creating provisional storage");
}
tmpStorage = new Storage(context); tmpStorage = new Storage(context);
Storage oldStorage = storages.putIfAbsent(context, tmpStorage); Storage oldStorage = storages.putIfAbsent(context, tmpStorage);
if (oldStorage != null) { if (oldStorage != null) {
if (K9.DEBUG) {
Timber.d("Another thread beat us to creating the Storage, returning that one"); Timber.d("Another thread beat us to creating the Storage, returning that one");
}
return oldStorage; return oldStorage;
} else { } else {
if (K9.DEBUG) {
Timber.d("Returning the Storage we created"); Timber.d("Returning the Storage we created");
}
return tmpStorage; return tmpStorage;
} }
} }
@ -177,9 +169,7 @@ public class Storage {
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
String key = cursor.getString(0); String key = cursor.getString(0);
String value = cursor.getString(1); String value = cursor.getString(1);
if (K9.DEBUG) {
Timber.d("Loading key '%s', value = '%s'", key, value); Timber.d("Loading key '%s', value = '%s'", key, value);
}
storage.put(key, value); storage.put(key, value);
} }
} finally { } finally {
@ -335,10 +325,8 @@ public class Storage {
if (cursor.moveToNext()) { if (cursor.moveToNext()) {
value = cursor.getString(0); value = cursor.getString(0);
if (K9.DEBUG) {
Timber.d("Loading key '%s', value = '%s'", key, value); Timber.d("Loading key '%s', value = '%s'", key, value);
} }
}
} finally { } finally {
Utility.closeQuietly(cursor); Utility.closeQuietly(cursor);
} }

View file

@ -29,17 +29,13 @@ public class StorageEditor {
String key = entry.getKey(); String key = entry.getKey();
Object value = entry.getValue(); Object value = entry.getValue();
if (key != null && value != null) { if (key != null && value != null) {
if (K9.DEBUG) {
Timber.d("Copying key '%s', value '%s'", key, value); Timber.d("Copying key '%s', value '%s'", key, value);
}
changes.put(key, "" + value); changes.put(key, "" + value);
} else { } else {
if (K9.DEBUG) {
Timber.d("Skipping copying key '%s', value '%s'", key, value); Timber.d("Skipping copying key '%s', value '%s'", key, value);
} }
} }
} }
}
public boolean commit() { public boolean commit() {
try { try {

View file

@ -101,9 +101,7 @@ public class AttachmentProvider extends ContentProvider {
} }
if (attachmentInfo == null) { if (attachmentInfo == null) {
if (K9.DEBUG) {
Timber.d("No attachment info for ID: %s", id); Timber.d("No attachment info for ID: %s", id);
}
return null; return null;
} }

View file

@ -167,9 +167,7 @@ public class AttachmentTempFileProvider extends FileProvider {
return; return;
} }
if (K9.DEBUG) {
Timber.d("Unregistering temp file cleanup receiver"); Timber.d("Unregistering temp file cleanup receiver");
}
context.unregisterReceiver(cleanupReceiver); context.unregisterReceiver(cleanupReceiver);
cleanupReceiver = null; cleanupReceiver = null;
} }
@ -180,9 +178,8 @@ public class AttachmentTempFileProvider extends FileProvider {
if (cleanupReceiver != null) { if (cleanupReceiver != null) {
return; return;
} }
if (K9.DEBUG) {
Timber.d("Registering temp file cleanup receiver"); Timber.d("Registering temp file cleanup receiver");
}
cleanupReceiver = new AttachmentTempFileProviderCleanupReceiver(); cleanupReceiver = new AttachmentTempFileProviderCleanupReceiver();
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
@ -199,9 +196,7 @@ public class AttachmentTempFileProvider extends FileProvider {
throw new IllegalArgumentException("onReceive called with action that isn't screen off!"); throw new IllegalArgumentException("onReceive called with action that isn't screen off!");
} }
if (K9.DEBUG) {
Timber.d("Cleaning up temp files"); Timber.d("Cleaning up temp files");
}
boolean allFilesDeleted = deleteOldTemporaryFiles(context); boolean allFilesDeleted = deleteOldTemporaryFiles(context);
if (allFilesDeleted) { if (allFilesDeleted) {

View file

@ -132,7 +132,7 @@ public class DecryptedFileProvider extends FileProvider {
InputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pfd); InputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pfd);
decodedInputStream = new QuotedPrintableInputStream(inputStream); decodedInputStream = new QuotedPrintableInputStream(inputStream);
} else { // no or unknown encoding } else { // no or unknown encoding
if (K9.DEBUG && !TextUtils.isEmpty(encoding)) { if (!TextUtils.isEmpty(encoding)) {
Timber.e("unsupported encoding, returning raw stream"); Timber.e("unsupported encoding, returning raw stream");
} }
return pfd; return pfd;
@ -173,9 +173,7 @@ public class DecryptedFileProvider extends FileProvider {
return; return;
} }
if (K9.DEBUG) {
Timber.d("Unregistering temp file cleanup receiver"); Timber.d("Unregistering temp file cleanup receiver");
}
context.unregisterReceiver(cleanupReceiver); context.unregisterReceiver(cleanupReceiver);
cleanupReceiver = null; cleanupReceiver = null;
} }
@ -186,9 +184,8 @@ public class DecryptedFileProvider extends FileProvider {
if (cleanupReceiver != null) { if (cleanupReceiver != null) {
return; return;
} }
if (K9.DEBUG) {
Timber.d("Registering temp file cleanup receiver"); Timber.d("Registering temp file cleanup receiver");
}
cleanupReceiver = new DecryptedFileProviderCleanupReceiver(); cleanupReceiver = new DecryptedFileProviderCleanupReceiver();
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
@ -205,9 +202,7 @@ public class DecryptedFileProvider extends FileProvider {
throw new IllegalArgumentException("onReceive called with action that isn't screen off!"); throw new IllegalArgumentException("onReceive called with action that isn't screen off!");
} }
if (K9.DEBUG) {
Timber.d("Cleaning up temp files"); Timber.d("Cleaning up temp files");
}
boolean allFilesDeleted = deleteOldTemporaryFiles(context); boolean allFilesDeleted = deleteOldTemporaryFiles(context);
if (allFilesDeleted) { if (allFilesDeleted) {

View file

@ -123,9 +123,7 @@ public class MessageProvider extends ContentProvider {
return null; return null;
} }
if (K9.DEBUG) {
Timber.v("MessageProvider/getType: %s", uri); Timber.v("MessageProvider/getType: %s", uri);
}
return null; return null;
} }
@ -136,9 +134,7 @@ public class MessageProvider extends ContentProvider {
return null; return null;
} }
if (K9.DEBUG) {
Timber.v("MessageProvider/query: %s", uri); Timber.v("MessageProvider/query: %s", uri);
}
int code = uriMatcher.match(uri); int code = uriMatcher.match(uri);
if (code == -1) { if (code == -1) {
@ -163,9 +159,7 @@ public class MessageProvider extends ContentProvider {
return 0; return 0;
} }
if (K9.DEBUG) {
Timber.v("MessageProvider/delete: %s", uri); Timber.v("MessageProvider/delete: %s", uri);
}
// Note: can only delete a message // Note: can only delete a message
@ -206,9 +200,7 @@ public class MessageProvider extends ContentProvider {
return null; return null;
} }
if (K9.DEBUG) {
Timber.v("MessageProvider/insert: %s", uri); Timber.v("MessageProvider/insert: %s", uri);
}
return null; return null;
} }
@ -219,9 +211,7 @@ public class MessageProvider extends ContentProvider {
return 0; return 0;
} }
if (K9.DEBUG) {
Timber.v("MessageProvider/update: %s", uri); Timber.v("MessageProvider/update: %s", uri);
}
// TBD // TBD

View file

@ -99,10 +99,8 @@ public class UnreadWidgetProvider extends AppWidgetProvider {
unreadCount = stats.unreadMessageCount; unreadCount = stats.unreadMessageCount;
} }
} catch (Exception e) { } catch (Exception e) {
if (K9.DEBUG) {
Timber.e(e, "Error getting widget configuration"); Timber.e(e, "Error getting widget configuration");
} }
}
if (unreadCount <= 0) { if (unreadCount <= 0) {
// Hide TextView for unread count if there are no unread messages. // Hide TextView for unread count if there are no unread messages.

View file

@ -25,7 +25,6 @@ public class BootReceiver extends CoreReceiver {
@Override @Override
public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) { public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) {
if (K9.DEBUG)
Timber.i("BootReceiver.onReceive %s", intent); Timber.i("BootReceiver.onReceive %s", intent);
final String action = intent.getAction(); final String action = intent.getAction();
@ -50,7 +49,6 @@ public class BootReceiver extends CoreReceiver {
} else if (FIRE_INTENT.equals(action)) { } else if (FIRE_INTENT.equals(action)) {
Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT); Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT);
String alarmedAction = alarmedIntent.getAction(); String alarmedAction = alarmedIntent.getAction();
if (K9.DEBUG)
Timber.i("BootReceiver Got alarm to fire alarmedIntent %s", alarmedAction); Timber.i("BootReceiver Got alarm to fire alarmedIntent %s", alarmedAction);
alarmedIntent.putExtra(WAKE_LOCK_ID, tmpWakeLockId); alarmedIntent.putExtra(WAKE_LOCK_ID, tmpWakeLockId);
tmpWakeLockId = null; tmpWakeLockId = null;
@ -58,7 +56,6 @@ public class BootReceiver extends CoreReceiver {
} else if (SCHEDULE_INTENT.equals(action)) { } else if (SCHEDULE_INTENT.equals(action)) {
long atTime = intent.getLongExtra(AT_TIME, -1); long atTime = intent.getLongExtra(AT_TIME, -1);
Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT); Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT);
if (K9.DEBUG)
Timber.i("BootReceiver Scheduling intent %s for %tc", alarmedIntent, atTime); Timber.i("BootReceiver Scheduling intent %s for %tc", alarmedIntent, atTime);
PendingIntent pi = buildPendingIntent(context, intent); PendingIntent pi = buildPendingIntent(context, intent);
@ -67,7 +64,6 @@ public class BootReceiver extends CoreReceiver {
alarmMgr.set(AlarmManager.RTC_WAKEUP, atTime, pi); alarmMgr.set(AlarmManager.RTC_WAKEUP, atTime, pi);
} else if (CANCEL_INTENT.equals(action)) { } else if (CANCEL_INTENT.equals(action)) {
Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT); Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT);
if (K9.DEBUG)
Timber.i("BootReceiver Canceling alarmedIntent %s", alarmedIntent); Timber.i("BootReceiver Canceling alarmedIntent %s", alarmedIntent);
PendingIntent pi = buildPendingIntent(context, intent); PendingIntent pi = buildPendingIntent(context, intent);
@ -94,8 +90,8 @@ public class BootReceiver extends CoreReceiver {
} }
public static void scheduleIntent(Context context, long atTime, Intent alarmedIntent) { public static void scheduleIntent(Context context, long atTime, Intent alarmedIntent) {
if (K9.DEBUG)
Timber.i("BootReceiver Got request to schedule alarmedIntent %s", alarmedIntent.getAction()); Timber.i("BootReceiver Got request to schedule alarmedIntent %s", alarmedIntent.getAction());
Intent i = new Intent(); Intent i = new Intent();
i.setClass(context, BootReceiver.class); i.setClass(context, BootReceiver.class);
i.setAction(SCHEDULE_INTENT); i.setAction(SCHEDULE_INTENT);
@ -105,8 +101,8 @@ public class BootReceiver extends CoreReceiver {
} }
public static void cancelIntent(Context context, Intent alarmedIntent) { public static void cancelIntent(Context context, Intent alarmedIntent) {
if (K9.DEBUG)
Timber.i("BootReceiver Got request to cancel alarmedIntent %s", alarmedIntent.getAction()); Timber.i("BootReceiver Got request to cancel alarmedIntent %s", alarmedIntent.getAction());
Intent i = new Intent(); Intent i = new Intent();
i.setClass(context, BootReceiver.class); i.setClass(context, BootReceiver.class);
i.setAction(CANCEL_INTENT); i.setAction(CANCEL_INTENT);

View file

@ -30,7 +30,6 @@ public class CoreReceiver extends BroadcastReceiver {
wakeLock.acquire(K9.BOOT_RECEIVER_WAKE_LOCK_TIMEOUT); wakeLock.acquire(K9.BOOT_RECEIVER_WAKE_LOCK_TIMEOUT);
Integer tmpWakeLockId = wakeLockSeq.getAndIncrement(); Integer tmpWakeLockId = wakeLockSeq.getAndIncrement();
wakeLocks.put(tmpWakeLockId, wakeLock); wakeLocks.put(tmpWakeLockId, wakeLock);
if (K9.DEBUG)
Timber.v("CoreReceiver Created wakeLock %d", tmpWakeLockId); Timber.v("CoreReceiver Created wakeLock %d", tmpWakeLockId);
return tmpWakeLockId; return tmpWakeLockId;
} }
@ -39,7 +38,6 @@ public class CoreReceiver extends BroadcastReceiver {
if (wakeLockId != null) { if (wakeLockId != null) {
TracingWakeLock wl = wakeLocks.remove(wakeLockId); TracingWakeLock wl = wakeLocks.remove(wakeLockId);
if (wl != null) { if (wl != null) {
if (K9.DEBUG)
Timber.v("CoreReceiver Releasing wakeLock %d", wakeLockId); Timber.v("CoreReceiver Releasing wakeLock %d", wakeLockId);
wl.release(); wl.release();
} else { } else {
@ -52,12 +50,11 @@ public class CoreReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Integer tmpWakeLockId = CoreReceiver.getWakeLock(context); Integer tmpWakeLockId = CoreReceiver.getWakeLock(context);
try { try {
if (K9.DEBUG)
Timber.i("CoreReceiver.onReceive %s", intent); Timber.i("CoreReceiver.onReceive %s", intent);
if (CoreReceiver.WAKE_LOCK_RELEASE.equals(intent.getAction())) { if (CoreReceiver.WAKE_LOCK_RELEASE.equals(intent.getAction())) {
Integer wakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1); Integer wakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1);
if (wakeLockId != -1) { if (wakeLockId != -1) {
if (K9.DEBUG)
Timber.v("CoreReceiver Release wakeLock %d", wakeLockId); Timber.v("CoreReceiver Release wakeLock %d", wakeLockId);
CoreReceiver.releaseWakeLock(wakeLockId); CoreReceiver.releaseWakeLock(wakeLockId);
} }
@ -74,8 +71,8 @@ public class CoreReceiver extends BroadcastReceiver {
} }
public static void releaseWakeLock(Context context, int wakeLockId) { public static void releaseWakeLock(Context context, int wakeLockId) {
if (K9.DEBUG)
Timber.v("CoreReceiver Got request to release wakeLock %d", wakeLockId); Timber.v("CoreReceiver Got request to release wakeLock %d", wakeLockId);
Intent i = new Intent(); Intent i = new Intent();
i.setClass(context, CoreReceiver.class); i.setClass(context, CoreReceiver.class);
i.setAction(WAKE_LOCK_RELEASE); i.setAction(WAKE_LOCK_RELEASE);

View file

@ -190,9 +190,7 @@ public abstract class CoreService extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
if (K9.DEBUG) {
Timber.i("CoreService: %s.onCreate()", className); Timber.i("CoreService: %s.onCreate()", className);
}
mThreadPool = Executors.newFixedThreadPool(1); // Must be single threaded mThreadPool = Executors.newFixedThreadPool(1); // Must be single threaded
} }
@ -217,9 +215,7 @@ public abstract class CoreService extends Service {
TracingWakeLock wakeLock = acquireWakeLock(this, "CoreService onStart", TracingWakeLock wakeLock = acquireWakeLock(this, "CoreService onStart",
K9.MAIL_SERVICE_WAKE_LOCK_TIMEOUT); K9.MAIL_SERVICE_WAKE_LOCK_TIMEOUT);
if (K9.DEBUG) {
Timber.i("CoreService: %s.onStart(%s, %d)", className, intent, startId); Timber.i("CoreService: %s.onStart(%s, %d)", className, intent, startId);
}
// If we were started by BootReceiver, release the wake lock acquired there. // If we were started by BootReceiver, release the wake lock acquired there.
int wakeLockId = intent.getIntExtra(BootReceiver.WAKE_LOCK_ID, -1); int wakeLockId = intent.getIntExtra(BootReceiver.WAKE_LOCK_ID, -1);
@ -231,18 +227,14 @@ public abstract class CoreService extends Service {
// release it. // release it.
int coreWakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1); int coreWakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1);
if (coreWakeLockId != -1) { if (coreWakeLockId != -1) {
if (K9.DEBUG) {
Timber.d("Got core wake lock id %d", coreWakeLockId); Timber.d("Got core wake lock id %d", coreWakeLockId);
}
// Remove wake lock from the registry // Remove wake lock from the registry
TracingWakeLock coreWakeLock = sWakeLocks.remove(coreWakeLockId); TracingWakeLock coreWakeLock = sWakeLocks.remove(coreWakeLockId);
// Release wake lock // Release wake lock
if (coreWakeLock != null) { if (coreWakeLock != null) {
if (K9.DEBUG) {
Timber.d("Found core wake lock with id %d, releasing", coreWakeLockId); Timber.d("Found core wake lock with id %d, releasing", coreWakeLockId);
}
coreWakeLock.release(); coreWakeLock.release();
} }
} }
@ -305,10 +297,8 @@ public abstract class CoreService extends Service {
// Get the sync status // Get the sync status
boolean oldIsSyncDisabled = MailService.isSyncDisabled(); boolean oldIsSyncDisabled = MailService.isSyncDisabled();
if (K9.DEBUG) {
Timber.d("CoreService (%s) running Runnable %d with startId %d", Timber.d("CoreService (%s) running Runnable %d with startId %d",
className, runner.hashCode(), startId); className, runner.hashCode(), startId);
}
// Run the supplied code // Run the supplied code
runner.run(); runner.run();
@ -321,10 +311,9 @@ public abstract class CoreService extends Service {
} finally { } finally {
// Making absolutely sure stopSelf() will be called // Making absolutely sure stopSelf() will be called
try { try {
if (K9.DEBUG) {
Timber.d("CoreService (%s) completed Runnable %d with startId %d", Timber.d("CoreService (%s) completed Runnable %d with startId %d",
className, runner.hashCode(), startId); className, runner.hashCode(), startId);
}
wakeLock.release(); wakeLock.release();
} finally { } finally {
if (autoShutdown && startId != null) { if (autoShutdown && startId != null) {
@ -345,10 +334,7 @@ public abstract class CoreService extends Service {
serviceShutdownScheduled = startId != null; serviceShutdownScheduled = startId != null;
} }
} else { } else {
if (K9.DEBUG) { Timber.d("CoreService (%s) queueing Runnable %d with startId %d", className, runner.hashCode(), startId);
Timber.d("CoreService (%s) queueing Runnable %d with startId %d",
className, runner.hashCode(), startId);
}
try { try {
mThreadPool.execute(myRunner); mThreadPool.execute(myRunner);
@ -397,9 +383,7 @@ public abstract class CoreService extends Service {
*/ */
@Override @Override
public void onDestroy() { public void onDestroy() {
if (K9.DEBUG) {
Timber.i("CoreService: %s.onDestroy()", className); Timber.i("CoreService: %s.onDestroy()", className);
}
// Shut down thread pool // Shut down thread pool
mShutdown = true; mShutdown = true;

View file

@ -120,10 +120,7 @@ public class DatabaseUpgradeService extends Service {
boolean success = mRunning.compareAndSet(false, true); boolean success = mRunning.compareAndSet(false, true);
if (success) { if (success) {
// The service wasn't running yet. // The service wasn't running yet.
if (K9.DEBUG) {
Timber.i("DatabaseUpgradeService started"); Timber.i("DatabaseUpgradeService started");
}
acquireWakelock(); acquireWakelock();
@ -159,10 +156,7 @@ public class DatabaseUpgradeService extends Service {
*/ */
private void stopService() { private void stopService() {
stopSelf(); stopSelf();
if (K9.DEBUG) {
Timber.i("DatabaseUpgradeService stopped"); Timber.i("DatabaseUpgradeService stopped");
}
releaseWakelock(); releaseWakelock();
mRunning.set(false); mRunning.set(false);

View file

@ -83,7 +83,6 @@ public class MailService extends CoreService {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
if (K9.DEBUG)
Timber.v("***** MailService *****: onCreate"); Timber.v("***** MailService *****: onCreate");
} }
@ -114,39 +113,32 @@ public class MailService extends CoreService {
syncNoConnectivity = !hasConnectivity; syncNoConnectivity = !hasConnectivity;
syncBlocked = !(doBackground && hasConnectivity); syncBlocked = !(doBackground && hasConnectivity);
if (K9.DEBUG)
Timber.i("MailService.onStart(%s, %d), hasConnectivity = %s, doBackground = %s", Timber.i("MailService.onStart(%s, %d), hasConnectivity = %s, doBackground = %s",
intent, startId, hasConnectivity, doBackground); intent, startId, hasConnectivity, doBackground);
// MessagingController.getInstance(getApplication()).addListener(mListener); // MessagingController.getInstance(getApplication()).addListener(mListener);
if (ACTION_CHECK_MAIL.equals(intent.getAction())) { if (ACTION_CHECK_MAIL.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("***** MailService *****: checking mail"); Timber.i("***** MailService *****: checking mail");
if (hasConnectivity && doBackground) { if (hasConnectivity && doBackground) {
PollService.startService(this); PollService.startService(this);
} }
reschedulePollInBackground(hasConnectivity, doBackground, startId, false); reschedulePollInBackground(hasConnectivity, doBackground, startId, false);
} else if (ACTION_CANCEL.equals(intent.getAction())) { } else if (ACTION_CANCEL.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.v("***** MailService *****: cancel"); Timber.v("***** MailService *****: cancel");
cancel(); cancel();
} else if (ACTION_RESET.equals(intent.getAction())) { } else if (ACTION_RESET.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.v("***** MailService *****: reschedule"); Timber.v("***** MailService *****: reschedule");
rescheduleAllInBackground(hasConnectivity, doBackground, startId); rescheduleAllInBackground(hasConnectivity, doBackground, startId);
} else if (ACTION_RESTART_PUSHERS.equals(intent.getAction())) { } else if (ACTION_RESTART_PUSHERS.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.v("***** MailService *****: restarting pushers"); Timber.v("***** MailService *****: restarting pushers");
reschedulePushersInBackground(hasConnectivity, doBackground, startId); reschedulePushersInBackground(hasConnectivity, doBackground, startId);
} else if (ACTION_RESCHEDULE_POLL.equals(intent.getAction())) { } else if (ACTION_RESCHEDULE_POLL.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.v("***** MailService *****: rescheduling poll"); Timber.v("***** MailService *****: rescheduling poll");
reschedulePollInBackground(hasConnectivity, doBackground, startId, true); reschedulePollInBackground(hasConnectivity, doBackground, startId, true);
} else if (ACTION_REFRESH_PUSHERS.equals(intent.getAction())) { } else if (ACTION_REFRESH_PUSHERS.equals(intent.getAction())) {
refreshPushersInBackground(hasConnectivity, doBackground, startId); refreshPushersInBackground(hasConnectivity, doBackground, startId);
} else if (CONNECTIVITY_CHANGE.equals(intent.getAction())) { } else if (CONNECTIVITY_CHANGE.equals(intent.getAction())) {
rescheduleAllInBackground(hasConnectivity, doBackground, startId); rescheduleAllInBackground(hasConnectivity, doBackground, startId);
if (K9.DEBUG)
Timber.i("Got connectivity action with hasConnectivity = %s, doBackground = %s", Timber.i("Got connectivity action with hasConnectivity = %s, doBackground = %s",
hasConnectivity, doBackground); hasConnectivity, doBackground);
} else if (CANCEL_CONNECTIVITY_NOTICE.equals(intent.getAction())) { } else if (CANCEL_CONNECTIVITY_NOTICE.equals(intent.getAction())) {
@ -157,7 +149,6 @@ public class MailService extends CoreService {
MessagingController.getInstance(getApplication()).systemStatusChanged(); MessagingController.getInstance(getApplication()).systemStatusChanged();
} }
if (K9.DEBUG)
Timber.i("MailService.onStart took %d ms", currentTimeMillis() - startTime); Timber.i("MailService.onStart took %d ms", currentTimeMillis() - startTime);
return START_NOT_STICKY; return START_NOT_STICKY;
@ -165,7 +156,6 @@ public class MailService extends CoreService {
@Override @Override
public void onDestroy() { public void onDestroy() {
if (K9.DEBUG)
Timber.v("***** MailService *****: onDestroy()"); Timber.v("***** MailService *****: onDestroy()");
super.onDestroy(); super.onDestroy();
// MessagingController.getInstance(getApplication()).removeListener(mListener); // MessagingController.getInstance(getApplication()).removeListener(mListener);
@ -182,8 +172,8 @@ public class MailService extends CoreService {
public static void saveLastCheckEnd(Context context) { public static void saveLastCheckEnd(Context context) {
long lastCheckEnd = System.currentTimeMillis(); long lastCheckEnd = System.currentTimeMillis();
if (K9.DEBUG)
Timber.i("Saving lastCheckEnd = %tc", lastCheckEnd); Timber.i("Saving lastCheckEnd = %tc", lastCheckEnd);
Preferences prefs = Preferences.getPreferences(context); Preferences prefs = Preferences.getPreferences(context);
Storage storage = prefs.getStorage(); Storage storage = prefs.getStorage();
StorageEditor editor = storage.edit(); StorageEditor editor = storage.edit();
@ -240,9 +230,7 @@ public class MailService extends CoreService {
boolean considerLastCheckEnd) { boolean considerLastCheckEnd) {
if (!(hasConnectivity && doBackground)) { if (!(hasConnectivity && doBackground)) {
if (K9.DEBUG) {
Timber.i("No connectivity, canceling check for %s", getApplication().getPackageName()); Timber.i("No connectivity, canceling check for %s", getApplication().getPackageName());
}
nextCheck = -1; nextCheck = -1;
cancel(); cancel();
@ -277,9 +265,7 @@ public class MailService extends CoreService {
editor.commit(); editor.commit();
if (shortestInterval == -1) { if (shortestInterval == -1) {
if (K9.DEBUG) {
Timber.i("No next check scheduled for package %s", getApplication().getPackageName()); Timber.i("No next check scheduled for package %s", getApplication().getPackageName());
}
nextCheck = -1; nextCheck = -1;
pollingRequested = false; pollingRequested = false;
@ -290,22 +276,17 @@ public class MailService extends CoreService {
!considerLastCheckEnd ? System.currentTimeMillis() : lastCheckEnd); !considerLastCheckEnd ? System.currentTimeMillis() : lastCheckEnd);
long nextTime = base + delay; long nextTime = base + delay;
if (K9.DEBUG) {
Timber.i("previousInterval = %d, shortestInterval = %d, lastCheckEnd = %tc, considerLastCheckEnd = %tc", Timber.i("previousInterval = %d, shortestInterval = %d, lastCheckEnd = %tc, considerLastCheckEnd = %tc",
previousInterval, previousInterval,
shortestInterval, shortestInterval,
lastCheckEnd, lastCheckEnd,
considerLastCheckEnd); considerLastCheckEnd);
}
nextCheck = nextTime; nextCheck = nextTime;
pollingRequested = true; pollingRequested = true;
try { try {
if (K9.DEBUG) { Timber.i("Next check for package %s scheduled for %tc", getApplication().getPackageName(), nextTime);
Timber.i("Next check for package %s scheduled for %tc",
getApplication().getPackageName(), nextTime);
}
} catch (Exception e) { } catch (Exception e) {
// I once got a NullPointerException deep in new Date(); // I once got a NullPointerException deep in new Date();
Timber.e(e, "Exception while logging"); Timber.e(e, "Exception while logging");
@ -343,17 +324,12 @@ public class MailService extends CoreService {
} }
private void reschedulePushers(boolean hasConnectivity, boolean doBackground) { private void reschedulePushers(boolean hasConnectivity, boolean doBackground) {
if (K9.DEBUG) {
Timber.i("Rescheduling pushers"); Timber.i("Rescheduling pushers");
}
stopPushers(); stopPushers();
if (!(hasConnectivity && doBackground)) { if (!(hasConnectivity && doBackground)) {
if (K9.DEBUG) { Timber.i("Not scheduling pushers: connectivity? %s -- doBackground? %s", hasConnectivity, doBackground);
Timber.i("Not scheduling pushers: connectivity? %s -- doBackground? %s",
hasConnectivity, doBackground);
}
return; return;
} }
@ -365,8 +341,8 @@ public class MailService extends CoreService {
private void setupPushers() { private void setupPushers() {
boolean pushing = false; boolean pushing = false;
for (Account account : Preferences.getPreferences(MailService.this).getAccounts()) { for (Account account : Preferences.getPreferences(MailService.this).getAccounts()) {
if (K9.DEBUG)
Timber.i("Setting up pushers for account %s", account.getDescription()); Timber.i("Setting up pushers for account %s", account.getDescription());
if (account.isEnabled() && account.isAvailable(getApplicationContext())) { if (account.isEnabled() && account.isAvailable(getApplicationContext())) {
pushing |= MessagingController.getInstance(getApplication()).setupPushing(account); pushing |= MessagingController.getInstance(getApplication()).setupPushing(account);
} else { } else {
@ -382,26 +358,24 @@ public class MailService extends CoreService {
private void refreshPushers() { private void refreshPushers() {
try { try {
long nowTime = System.currentTimeMillis(); long nowTime = System.currentTimeMillis();
if (K9.DEBUG)
Timber.i("Refreshing pushers"); Timber.i("Refreshing pushers");
Collection<Pusher> pushers = MessagingController.getInstance(getApplication()).getPushers(); Collection<Pusher> pushers = MessagingController.getInstance(getApplication()).getPushers();
for (Pusher pusher : pushers) { for (Pusher pusher : pushers) {
long lastRefresh = pusher.getLastRefresh(); long lastRefresh = pusher.getLastRefresh();
int refreshInterval = pusher.getRefreshInterval(); int refreshInterval = pusher.getRefreshInterval();
long sinceLast = nowTime - lastRefresh; long sinceLast = nowTime - lastRefresh;
if (sinceLast + 10000 > refreshInterval) { // Add 10 seconds to keep pushers in sync, avoid drift if (sinceLast + 10000 > refreshInterval) { // Add 10 seconds to keep pushers in sync, avoid drift
if (K9.DEBUG) {
Timber.d("PUSHREFRESH: refreshing lastRefresh = %d, interval = %d, nowTime = %d, " + Timber.d("PUSHREFRESH: refreshing lastRefresh = %d, interval = %d, nowTime = %d, " +
"sinceLast = %d", "sinceLast = %d",
lastRefresh, lastRefresh,
refreshInterval, refreshInterval,
nowTime, nowTime,
sinceLast); sinceLast);
}
pusher.refresh(); pusher.refresh();
pusher.setLastRefresh(nowTime); pusher.setLastRefresh(nowTime);
} else { } else {
if (K9.DEBUG) {
Timber.d("PUSHREFRESH: NOT refreshing lastRefresh = %d, interval = %d, nowTime = %d, " + Timber.d("PUSHREFRESH: NOT refreshing lastRefresh = %d, interval = %d, nowTime = %d, " +
"sinceLast = %d", "sinceLast = %d",
lastRefresh, lastRefresh,
@ -410,11 +384,8 @@ public class MailService extends CoreService {
sinceLast); sinceLast);
} }
} }
}
// Whenever we refresh our pushers, send any unsent messages // Whenever we refresh our pushers, send any unsent messages
if (K9.DEBUG) {
Timber.d("PUSHREFRESH: trying to send mail in all folders!"); Timber.d("PUSHREFRESH: trying to send mail in all folders!");
}
MessagingController.getInstance(getApplication()).sendPendingMessages(null); MessagingController.getInstance(getApplication()).sendPendingMessages(null);
@ -433,13 +404,13 @@ public class MailService extends CoreService {
minInterval = interval; minInterval = interval;
} }
} }
if (K9.DEBUG) {
Timber.v("Pusher refresh interval = %d", minInterval); Timber.v("Pusher refresh interval = %d", minInterval);
}
if (minInterval > 0) { if (minInterval > 0) {
long nextTime = System.currentTimeMillis() + minInterval; long nextTime = System.currentTimeMillis() + minInterval;
if (K9.DEBUG)
Timber.d("Next pusher refresh scheduled for %tc", nextTime); Timber.d("Next pusher refresh scheduled for %tc", nextTime);
Intent i = new Intent(this, MailService.class); Intent i = new Intent(this, MailService.class);
i.setAction(ACTION_REFRESH_PUSHERS); i.setAction(ACTION_REFRESH_PUSHERS);
BootReceiver.scheduleIntent(MailService.this, nextTime, i); BootReceiver.scheduleIntent(MailService.this, nextTime, i);

View file

@ -45,26 +45,22 @@ public class PollService extends CoreService {
@Override @Override
public int startService(Intent intent, int startId) { public int startService(Intent intent, int startId) {
if (START_SERVICE.equals(intent.getAction())) { if (START_SERVICE.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("PollService started with startId = %d", startId); Timber.i("PollService started with startId = %d", startId);
MessagingController controller = MessagingController.getInstance(getApplication()); MessagingController controller = MessagingController.getInstance(getApplication());
Listener listener = (Listener)controller.getCheckMailListener(); Listener listener = (Listener)controller.getCheckMailListener();
if (listener == null) { if (listener == null) {
if (K9.DEBUG)
Timber.i("***** PollService *****: starting new check"); Timber.i("***** PollService *****: starting new check");
mListener.setStartId(startId); mListener.setStartId(startId);
mListener.wakeLockAcquire(); mListener.wakeLockAcquire();
controller.setCheckMailListener(mListener); controller.setCheckMailListener(mListener);
controller.checkMail(this, null, false, false, mListener); controller.checkMail(this, null, false, false, mListener);
} else { } else {
if (K9.DEBUG)
Timber.i("***** PollService *****: renewing WakeLock"); Timber.i("***** PollService *****: renewing WakeLock");
listener.setStartId(startId); listener.setStartId(startId);
listener.wakeLockAcquire(); listener.wakeLockAcquire();
} }
} else if (STOP_SERVICE.equals(intent.getAction())) { } else if (STOP_SERVICE.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("PollService stopping"); Timber.i("PollService stopping");
stopSelf(); stopSelf();
} }
@ -131,16 +127,13 @@ public class PollService extends CoreService {
MailService.actionReschedulePoll(PollService.this, null); MailService.actionReschedulePoll(PollService.this, null);
wakeLockRelease(); wakeLockRelease();
if (K9.DEBUG)
Timber.i("PollService stopping with startId = %d", startId);
Timber.i("PollService stopping with startId = %d", startId);
stopSelf(startId); stopSelf(startId);
} }
@Override @Override
public void checkMailFinished(Context context, Account account) { public void checkMailFinished(Context context, Account account) {
if (K9.DEBUG)
Timber.v("***** PollService *****: checkMailFinished"); Timber.v("***** PollService *****: checkMailFinished");
release(); release();
} }

View file

@ -30,10 +30,8 @@ public class PushService extends CoreService {
public int startService(Intent intent, int startId) { public int startService(Intent intent, int startId) {
int startFlag = START_STICKY; int startFlag = START_STICKY;
if (START_SERVICE.equals(intent.getAction())) { if (START_SERVICE.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("PushService started with startId = %d", startId); Timber.i("PushService started with startId = %d", startId);
} else if (STOP_SERVICE.equals(intent.getAction())) { } else if (STOP_SERVICE.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("PushService stopping with startId = %d", startId); Timber.i("PushService stopping with startId = %d", startId);
stopSelf(startId); stopSelf(startId);
startFlag = START_NOT_STICKY; startFlag = START_NOT_STICKY;

View file

@ -18,7 +18,6 @@ import static com.fsck.k9.remotecontrol.K9RemoteControl.*;
public class RemoteControlReceiver extends CoreReceiver { public class RemoteControlReceiver extends CoreReceiver {
@Override @Override
public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) { public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) {
if (K9.DEBUG)
Timber.i("RemoteControlReceiver.onReceive %s", intent); Timber.i("RemoteControlReceiver.onReceive %s", intent);
if (K9RemoteControl.K9_SET.equals(intent.getAction())) { if (K9RemoteControl.K9_SET.equals(intent.getAction())) {

View file

@ -37,21 +37,17 @@ public class RemoteControlService extends CoreService {
@Override @Override
public int startService(final Intent intent, final int startId) { public int startService(final Intent intent, final int startId) {
if (K9.DEBUG)
Timber.i("RemoteControlService started with startId = %d", startId); Timber.i("RemoteControlService started with startId = %d", startId);
final Preferences preferences = Preferences.getPreferences(this); final Preferences preferences = Preferences.getPreferences(this);
if (RESCHEDULE_ACTION.equals(intent.getAction())) { if (RESCHEDULE_ACTION.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("RemoteControlService requesting MailService poll reschedule"); Timber.i("RemoteControlService requesting MailService poll reschedule");
MailService.actionReschedulePoll(this, null); MailService.actionReschedulePoll(this, null);
} }
if (PUSH_RESTART_ACTION.equals(intent.getAction())) { if (PUSH_RESTART_ACTION.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("RemoteControlService requesting MailService push restart"); Timber.i("RemoteControlService requesting MailService push restart");
MailService.actionRestartPushers(this, null); MailService.actionRestartPushers(this, null);
} else if (RemoteControlService.SET_ACTION.equals(intent.getAction())) { } else if (RemoteControlService.SET_ACTION.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("RemoteControlService got request to change settings"); Timber.i("RemoteControlService got request to change settings");
execute(getApplication(), new Runnable() { execute(getApplication(), new Runnable() {
public void run() { public void run() {
@ -60,19 +56,18 @@ public class RemoteControlService extends CoreService {
boolean needsPushRestart = false; boolean needsPushRestart = false;
String uuid = intent.getStringExtra(K9_ACCOUNT_UUID); String uuid = intent.getStringExtra(K9_ACCOUNT_UUID);
boolean allAccounts = intent.getBooleanExtra(K9_ALL_ACCOUNTS, false); boolean allAccounts = intent.getBooleanExtra(K9_ALL_ACCOUNTS, false);
if (K9.DEBUG) {
if (allAccounts) { if (allAccounts) {
Timber.i("RemoteControlService changing settings for all accounts"); Timber.i("RemoteControlService changing settings for all accounts");
} else { } else {
Timber.i("RemoteControlService changing settings for account with UUID %s", uuid); Timber.i("RemoteControlService changing settings for account with UUID %s", uuid);
} }
}
List<Account> accounts = preferences.getAccounts(); List<Account> accounts = preferences.getAccounts();
for (Account account : accounts) { for (Account account : accounts) {
//warning: account may not be isAvailable() //warning: account may not be isAvailable()
if (allAccounts || account.getUuid().equals(uuid)) { if (allAccounts || account.getUuid().equals(uuid)) {
if (K9.DEBUG)
Timber.i("RemoteControlService changing settings for account %s", Timber.i("RemoteControlService changing settings for account %s",
account.getDescription()); account.getDescription());
@ -110,7 +105,7 @@ public class RemoteControlService extends CoreService {
account.save(Preferences.getPreferences(RemoteControlService.this)); account.save(Preferences.getPreferences(RemoteControlService.this));
} }
} }
if (K9.DEBUG)
Timber.i("RemoteControlService changing global settings"); Timber.i("RemoteControlService changing global settings");
String backgroundOps = intent.getStringExtra(K9_BACKGROUND_OPERATIONS); String backgroundOps = intent.getStringExtra(K9_BACKGROUND_OPERATIONS);

View file

@ -26,8 +26,8 @@ public class SleepService extends CoreService {
public static void sleep(Context context, long sleepTime, TracingWakeLock wakeLock, long wakeLockTimeout) { public static void sleep(Context context, long sleepTime, TracingWakeLock wakeLock, long wakeLockTimeout) {
Integer id = latchId.getAndIncrement(); Integer id = latchId.getAndIncrement();
if (K9.DEBUG)
Timber.d("SleepService Preparing CountDownLatch with id = %d, thread %s", id, currentThread().getName()); Timber.d("SleepService Preparing CountDownLatch with id = %d, thread %s", id, currentThread().getName());
SleepDatum sleepDatum = new SleepDatum(); SleepDatum sleepDatum = new SleepDatum();
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
sleepDatum.latch = latch; sleepDatum.latch = latch;
@ -48,7 +48,6 @@ public class SleepService extends CoreService {
try { try {
boolean countedDown = latch.await(sleepTime, TimeUnit.MILLISECONDS); boolean countedDown = latch.await(sleepTime, TimeUnit.MILLISECONDS);
if (!countedDown) { if (!countedDown) {
if (K9.DEBUG)
Timber.d("SleepService latch timed out for id = %d, thread %s", id, currentThread().getName()); Timber.d("SleepService latch timed out for id = %d, thread %s", id, currentThread().getName());
} }
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
@ -57,15 +56,16 @@ public class SleepService extends CoreService {
SleepDatum releaseDatum = sleepData.remove(id); SleepDatum releaseDatum = sleepData.remove(id);
if (releaseDatum == null) { if (releaseDatum == null) {
try { try {
if (K9.DEBUG)
Timber.d("SleepService waiting for reacquireLatch for id = %d, thread %s", Timber.d("SleepService waiting for reacquireLatch for id = %d, thread %s",
id, currentThread().getName()); id, currentThread().getName());
if (!sleepDatum.reacquireLatch.await(5000, TimeUnit.MILLISECONDS)) { if (!sleepDatum.reacquireLatch.await(5000, TimeUnit.MILLISECONDS)) {
Timber.w("SleepService reacquireLatch timed out for id = %d, thread %s", Timber.w("SleepService reacquireLatch timed out for id = %d, thread %s",
id, currentThread().getName()); id, currentThread().getName());
} else if (K9.DEBUG) } else {
Timber.d("SleepService reacquireLatch finished for id = %d, thread %s", Timber.d("SleepService reacquireLatch finished for id = %d, thread %s",
id, currentThread().getName()); id, currentThread().getName());
}
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
Timber.e(ie, "SleepService Interrupted while awaiting reacquireLatch"); Timber.e(ie, "SleepService Interrupted while awaiting reacquireLatch");
} }
@ -79,7 +79,6 @@ public class SleepService extends CoreService {
if (actualSleep < sleepTime) { if (actualSleep < sleepTime) {
Timber.w("SleepService sleep time too short: requested was %d, actual was %d", sleepTime, actualSleep); Timber.w("SleepService sleep time too short: requested was %d, actual was %d", sleepTime, actualSleep);
} else { } else {
if (K9.DEBUG)
Timber.d("SleepService requested sleep time was %d, actual was %d", sleepTime, actualSleep); Timber.d("SleepService requested sleep time was %d, actual was %d", sleepTime, actualSleep);
} }
} }
@ -92,14 +91,12 @@ public class SleepService extends CoreService {
if (latch == null) { if (latch == null) {
Timber.e("SleepService No CountDownLatch available with id = %s", id); Timber.e("SleepService No CountDownLatch available with id = %s", id);
} else { } else {
if (K9.DEBUG)
Timber.d("SleepService Counting down CountDownLatch with id = %d", id); Timber.d("SleepService Counting down CountDownLatch with id = %d", id);
latch.countDown(); latch.countDown();
} }
reacquireWakeLock(sleepDatum); reacquireWakeLock(sleepDatum);
sleepDatum.reacquireLatch.countDown(); sleepDatum.reacquireLatch.countDown();
} else { } else {
if (K9.DEBUG)
Timber.d("SleepService Sleep for id %d already finished", id); Timber.d("SleepService Sleep for id %d already finished", id);
} }
} }
@ -110,7 +107,6 @@ public class SleepService extends CoreService {
if (wakeLock != null) { if (wakeLock != null) {
synchronized (wakeLock) { synchronized (wakeLock) {
long timeout = sleepDatum.timeout; long timeout = sleepDatum.timeout;
if (K9.DEBUG)
Timber.d("SleepService Acquiring wakeLock for %d ms", timeout); Timber.d("SleepService Acquiring wakeLock for %d ms", timeout);
wakeLock.acquire(timeout); wakeLock.acquire(timeout);
} }

View file

@ -28,9 +28,7 @@ public class StorageGoneReceiver extends BroadcastReceiver {
return; return;
} }
if (K9.DEBUG) {
Timber.v("StorageGoneReceiver: %s", intent); Timber.v("StorageGoneReceiver: %s", intent);
}
final String path = uri.getPath(); final String path = uri.getPath();

View file

@ -23,9 +23,7 @@ public class StorageReceiver extends BroadcastReceiver {
return; return;
} }
if (K9.DEBUG) {
Timber.v("StorageReceiver: %s", intent); Timber.v("StorageReceiver: %s", intent);
}
final String path = uri.getPath(); final String path = uri.getPath();

View file

@ -250,10 +250,9 @@ public class QuotedMessagePresenter {
if (part != null) { // Shouldn't happen if we were the one who saved it. if (part != null) { // Shouldn't happen if we were the one who saved it.
quotedTextFormat = SimpleMessageFormat.HTML; quotedTextFormat = SimpleMessageFormat.HTML;
String text = MessageExtractor.getTextFromPart(part); String text = MessageExtractor.getTextFromPart(part);
if (K9.DEBUG) {
Timber.d("Loading message with offset %d, length %d. Text length is %d.", Timber.d("Loading message with offset %d, length %d. Text length is %d.",
bodyOffset, bodyLength, text.length()); bodyOffset, bodyLength, text.length());
}
if (bodyOffset + bodyLength > text.length()) { if (bodyOffset + bodyLength > text.length()) {
// The draft was edited outside of K-9 Mail? // The draft was edited outside of K-9 Mail?
@ -319,10 +318,9 @@ public class QuotedMessagePresenter {
} }
String messageText = MessageExtractor.getTextFromPart(textPart); String messageText = MessageExtractor.getTextFromPart(textPart);
if (K9.DEBUG) {
Timber.d("Loading message with offset %d, length %d. Text length is %d.", Timber.d("Loading message with offset %d, length %d. Text length is %d.",
bodyOffset, bodyLength, messageText.length()); bodyOffset, bodyLength, messageText.length());
}
// If we had a body length (and it was valid), separate the composition from the quoted text // If we had a body length (and it was valid), separate the composition from the quoted text
// and put them in their respective places in the UI. // and put them in their respective places in the UI.

View file

@ -470,9 +470,7 @@ public class MessageCryptoHelper {
private void handleCryptoOperationResult(MimeBodyPart outputPart) { private void handleCryptoOperationResult(MimeBodyPart outputPart) {
int resultCode = currentCryptoResult.getIntExtra(OpenPgpApi.RESULT_CODE, INVALID_OPENPGP_RESULT_CODE); int resultCode = currentCryptoResult.getIntExtra(OpenPgpApi.RESULT_CODE, INVALID_OPENPGP_RESULT_CODE);
if (K9.DEBUG) {
Timber.d("OpenPGP API decryptVerify result code: %d", resultCode); Timber.d("OpenPGP API decryptVerify result code: %d", resultCode);
}
switch (resultCode) { switch (resultCode) {
case INVALID_OPENPGP_RESULT_CODE: { case INVALID_OPENPGP_RESULT_CODE: {
@ -505,9 +503,7 @@ public class MessageCryptoHelper {
private void handleCryptoOperationError() { private void handleCryptoOperationError() {
OpenPgpError error = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_ERROR); OpenPgpError error = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
if (K9.DEBUG) {
Timber.w("OpenPGP API error: %s", error.getMessage()); Timber.w("OpenPGP API error: %s", error.getMessage());
}
onCryptoOperationFailed(error); onCryptoOperationFailed(error);
} }

View file

@ -211,9 +211,7 @@ public class AttachmentController {
writeAttachmentToStorage(tempFile); writeAttachmentToStorage(tempFile);
viewIntent = createViewIntentForFileUri(resolvedIntentInfo.getMimeType(), Uri.fromFile(tempFile)); viewIntent = createViewIntentForFileUri(resolvedIntentInfo.getMimeType(), Uri.fromFile(tempFile));
} catch (IOException e) { } catch (IOException e) {
if (K9.DEBUG) {
Timber.e(e, "Error while saving attachment to use file:// URI with ACTION_VIEW Intent"); Timber.e(e, "Error while saving attachment to use file:// URI with ACTION_VIEW Intent");
}
viewIntent = createViewIntentForAttachmentProviderUri(intentDataUri, MimeUtility.DEFAULT_ATTACHMENT_MIME_TYPE); viewIntent = createViewIntentForAttachmentProviderUri(intentDataUri, MimeUtility.DEFAULT_ATTACHMENT_MIME_TYPE);
} }
} else { } else {
@ -353,9 +351,7 @@ public class AttachmentController {
File directory = params[0]; File directory = params[0];
return saveAttachmentWithUniqueFileName(directory); return saveAttachmentWithUniqueFileName(directory);
} catch (IOException e) { } catch (IOException e) {
if (K9.DEBUG) {
Timber.e(e, "Error saving attachment"); Timber.e(e, "Error saving attachment");
}
return null; return null;
} }
} }

View file

@ -208,9 +208,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
private void displayMessage(MessageReference messageReference) { private void displayMessage(MessageReference messageReference) {
mMessageReference = messageReference; mMessageReference = messageReference;
if (K9.DEBUG) {
Timber.d("MessageView displaying message %s", mMessageReference); Timber.d("MessageView displaying message %s", mMessageReference);
}
mAccount = Preferences.getPreferences(getApplicationContext()).getAccount(mMessageReference.getAccountUuid()); mAccount = Preferences.getPreferences(getApplicationContext()).getAccount(mMessageReference.getAccountUuid());
messageLoaderHelper.asyncStartOrResumeLoadingMessage(messageReference, null); messageLoaderHelper.asyncStartOrResumeLoadingMessage(messageReference, null);

View file

@ -102,7 +102,6 @@ public class ClientCertificateSpinner extends LinearLayout {
KeyChain.choosePrivateKeyAlias(mActivity, new KeyChainAliasCallback() { KeyChain.choosePrivateKeyAlias(mActivity, new KeyChainAliasCallback() {
@Override @Override
public void alias(String alias) { public void alias(String alias) {
if (K9.DEBUG)
Timber.d("User has selected client certificate alias: %s", alias); Timber.d("User has selected client certificate alias: %s", alias);
setAlias(alias); setAlias(alias);

View file

@ -82,9 +82,7 @@ public class RigidWebView extends WebView {
if (mIgnoreNext) { if (mIgnoreNext) {
mIgnoreNext = false; mIgnoreNext = false;
if (recentlySized) { if (recentlySized) {
if (K9.DEBUG) {
Timber.w("Supressing size change in RigidWebView"); Timber.w("Supressing size change in RigidWebView");
}
return; return;
} }
} }