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

View file

@ -792,9 +792,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
private void onAccountChosen(Account account, Identity identity) {
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
if (action == Action.EDIT_DRAFT) {
@ -812,15 +810,12 @@ public class MessageCompose extends K9Activity implements OnClickListener,
// actual account switch
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();
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,
previousDraftId);
}
@ -1199,9 +1194,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
}
} 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.
@ -1235,9 +1228,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
repliedToMessageId = message.getMessageId();
referencedMessageIds = repliedToMessageId;
} 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.
@ -1369,12 +1360,11 @@ public class MessageCompose extends K9Activity implements OnClickListener,
**/
private void updateReferencedMessage() {
if (messageReference != null && messageReference.getFlag() != null) {
if (K9.DEBUG) {
Timber.d("Setting referenced message (%s, %s) flag to %s",
messageReference.getFolderName(),
messageReference.getUid(),
messageReference.getFlag());
}
Timber.d("Setting referenced message (%s, %s) flag to %s",
messageReference.getFolderName(),
messageReference.getUid(),
messageReference.getFlag());
final Account account = Preferences.getPreferences(context)
.getAccount(messageReference.getAccountUuid());
final String folderName = messageReference.getFolderName();

View file

@ -757,8 +757,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
// Swallow these events too to avoid the audible notification of a volume change
if (K9.useVolumeKeysForListNavigationEnabled()) {
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;
}
}

View file

@ -58,9 +58,7 @@ public class AttachmentContentLoader extends AsyncTaskLoader<Attachment> {
File file = File.createTempFile(FILENAME_PREFIX, null, context.getCacheDir());
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);
InputStream in = safeContentResolver.openInputStream(sourceAttachment.uri);

View file

@ -53,9 +53,7 @@ public class TemporaryAttachmentStore {
for (File file : files) {
if (file.lastModified() < cutOffTime) {
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 {
Timber.w("Couldn't delete from temporary attachment store: %s", file.getName());
}

View file

@ -199,12 +199,10 @@ public class MessagingController {
if (command != null) {
commandDescription = command.description;
if (K9.DEBUG) {
Timber.i("Running command '%s', seq = %s (%s priority)",
command.description,
command.sequence,
command.isForegroundPriority ? "foreground" : "background");
}
Timber.i("Running command '%s', seq = %s (%s priority)",
command.description,
command.sequence,
command.isForegroundPriority ? "foreground" : "background");
try {
command.runnable.run();
@ -224,9 +222,7 @@ public class MessagingController {
}.start();
}
if (K9.DEBUG) {
Timber.i(" Command '%s' completed", command.description);
}
Timber.i(" Command '%s' completed", command.description);
}
} catch (Exception e) {
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,
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() {
@Override
@ -599,9 +593,7 @@ public class MessagingController {
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
List<Message> remoteMessages = localFolder.extractNewMessages(messages);
@ -740,9 +732,7 @@ public class MessagingController {
Folder remoteFolder = 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)) {
l.synchronizeMailboxStarted(account, folder);
@ -760,9 +750,7 @@ public class MessagingController {
Exception commandException = null;
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 {
processPendingCommandsSynchronous(account);
@ -777,9 +765,7 @@ public class MessagingController {
* Get the message list from the local store and create an index of
* 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();
tLocalFolder = localStore.getFolder(folder);
@ -789,16 +775,12 @@ public class MessagingController {
Map<String, Long> localUidMap = localFolder.getAllMessagesAndEffectiveDates();
if (providedRemoteFolder != null) {
if (K9.DEBUG) {
Timber.v("SYNC: using providedRemoteFolder %s", folder);
}
Timber.v("SYNC: using providedRemoteFolder %s", folder);
remoteFolder = providedRemoteFolder;
} else {
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);
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.
*/
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);
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();
}
@ -857,9 +835,8 @@ public class MessagingController {
final List<Message> remoteMessages = new ArrayList<>();
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();
long earliestTimestamp = earliestDate != null ? earliestDate.getTime() : 0L;
@ -873,10 +850,8 @@ public class MessagingController {
remoteStart = 1;
}
if (K9.DEBUG) {
Timber.v("SYNC: About to get messages %d through %d for folder %s",
remoteStart, remoteMessageCount, folder);
}
Timber.v("SYNC: About to get messages %d through %d for folder %s",
remoteStart, remoteMessageCount, folder);
final AtomicInteger headerProgress = new AtomicInteger(0);
for (MessagingListener l : getListeners(listener)) {
@ -900,9 +875,8 @@ public class MessagingController {
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)) {
l.synchronizeMailboxHeadersFinished(account, folder, headerProgress.get(), remoteUidMap.size());
@ -959,13 +933,11 @@ public class MessagingController {
localFolder.setLastChecked(System.currentTimeMillis());
localFolder.setStatus(null);
if (K9.DEBUG) {
Timber.d("Done synchronizing folder %s:%s @ %tc with %d new messages",
account.getDescription(),
folder,
System.currentTimeMillis(),
newMessages);
}
Timber.d("Done synchronizing folder %s:%s @ %tc with %d new messages",
account.getDescription(),
folder,
System.currentTimeMillis(),
newMessages);
for (MessagingListener l : getListeners(listener)) {
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) {
handleAuthenticationFailure(account, true);
@ -1065,10 +1035,8 @@ public class MessagingController {
for (MessagingListener l : getListeners(listener)) {
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;
}
}
@ -1105,9 +1073,7 @@ public class MessagingController {
Date downloadStarted = new Date(); // now
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();
@ -1137,9 +1103,7 @@ public class MessagingController {
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();
final List<Message> largeMessages = new ArrayList<>();
@ -1164,9 +1128,7 @@ public class MessagingController {
}
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,
fp);
@ -1180,15 +1142,12 @@ public class MessagingController {
}
localFolder.setPushState(updatedPushState);
if (K9.DEBUG) {
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",
largeMessages.size(), smallMessages.size(), unsyncedMessages.size());
Timber.d("SYNC: Synced unsynced messages for folder %s", folder);
}
Timber.d("SYNC: Have %d large messages and %d small messages out of %d unsynced messages",
largeMessages.size(), smallMessages.size(), unsyncedMessages.size());
unsyncedMessages.clear();
/*
* Grab the content of the small messages first. This is going to
@ -1219,9 +1178,7 @@ public class MessagingController {
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) {
localFolder.purgeToVisibleLimit(new MessageRemovalListener() {
@ -1263,9 +1220,8 @@ public class MessagingController {
final List<Message> syncFlagMessages,
boolean flagSyncOnly) throws MessagingException {
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);
return;
}
@ -1275,15 +1231,11 @@ public class MessagingController {
if (localMessage == null) {
if (!flagSyncOnly) {
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);
} 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
localFolder.appendMessages(Collections.singletonList(message));
@ -1301,14 +1253,10 @@ public class MessagingController {
}
}
} 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 (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);
} else {
@ -1319,9 +1267,7 @@ public class MessagingController {
syncFlagMessages.add(message);
}
} 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());
}
}
@ -1386,9 +1332,7 @@ public class MessagingController {
final Date 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 true;
@ -1406,9 +1350,7 @@ public class MessagingController {
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,
fp, new MessageRetrievalListener<T>() {
@ -1436,10 +1378,8 @@ public class MessagingController {
newMessages.incrementAndGet();
}
if (K9.DEBUG) {
Timber.v("About to notify listeners that we got a new small message %s:%s:%s",
account, folder, message.getUid());
}
Timber.v("About to notify listeners that we got a new small message %s:%s:%s",
account, folder, message.getUid());
// Update the listener with what we've found
for (MessagingListener l : getListeners()) {
@ -1470,9 +1410,7 @@ 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,
@ -1485,9 +1423,9 @@ public class MessagingController {
FetchProfile fp) throws MessagingException {
final String folder = remoteFolder.getName();
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);
for (T message : largeMessages) {
@ -1501,10 +1439,10 @@ public class MessagingController {
} else {
downloadPartial(remoteFolder, localFolder, message);
}
if (K9.DEBUG) {
Timber.v("About to notify listeners that we got a new large message %s:%s:%s",
account, folder, message.getUid());
}
Timber.v("About to notify listeners that we got a new large message %s:%s:%s",
account, folder, message.getUid());
// Update the listener with what we've found
progress.incrementAndGet();
// TODO do we need to re-fetch this here?
@ -1526,10 +1464,8 @@ public class MessagingController {
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)
@ -1615,10 +1551,7 @@ public class MessagingController {
final String folder = remoteFolder.getName();
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();
fp.add(FetchProfile.Item.FLAGS);
@ -1755,9 +1688,8 @@ public class MessagingController {
try {
for (PendingCommand command : commands) {
processingCommand = command;
if (K9.DEBUG) {
Timber.d("Processing pending command '%s'", command);
}
Timber.d("Processing pending command '%s'", command);
for (MessagingListener l : getListeners()) {
l.pendingCommandStarted(account, command.getCommandName());
}
@ -1770,9 +1702,8 @@ public class MessagingController {
command.execute(this, account);
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) {
if (me.isPermanentFailure()) {
addErrorMessage(account, null, me);
@ -1990,17 +1921,13 @@ public class MessagingController {
+ srcFolder + " read/write", true);
}
if (K9.DEBUG) {
Timber.d("processingPendingMoveOrCopy: source folder = %s, %d messages, destination folder = %s, " +
"isCopy = %s", srcFolder, messages.size(), destFolder, isCopy);
}
Timber.d("processingPendingMoveOrCopy: source folder = %s, %d messages, destination folder = %s, " +
"isCopy = %s", srcFolder, messages.size(), destFolder, isCopy);
Map<String, String> remoteUidMap = null;
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;
if (K9.FOLDER_NONE.equals(destFolderName)) {
@ -2017,11 +1944,7 @@ public class MessagingController {
}
}
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();
}
@ -2123,9 +2046,8 @@ public class MessagingController {
if (account.getErrorFolderName().equals(folder)) {
return;
}
if (K9.DEBUG) {
Timber.d("processPendingExpunge: folder = %s", folder);
}
Timber.d("processPendingExpunge: folder = %s", folder);
Store remoteStore = account.getRemoteStore();
Folder remoteFolder = remoteStore.getFolder(folder);
@ -2138,9 +2060,8 @@ public class MessagingController {
return;
}
remoteFolder.expunge();
if (K9.DEBUG) {
Timber.d("processPendingExpunge: complete for folder = %s", folder);
}
Timber.d("processPendingExpunge: complete for folder = %s", folder);
} finally {
closeFolder(remoteFolder);
}
@ -2263,10 +2184,8 @@ public class MessagingController {
public void markAllMessagesRead(final Account account, final String folder) {
Timber.i("Marking all messages in %s:%s as read", account.getDescription(), folder);
if (K9.DEBUG) {
Timber.i("Marking all messages in %s:%s as read", account.getDescription(), folder);
}
PendingCommand command = PendingMarkAllAsRead.create(folder);
queuePendingCommand(account, command);
processPendingCommands(account);
@ -2641,9 +2560,7 @@ public class MessagingController {
l.loadAttachmentFinished(account, message, part);
}
} catch (MessagingException me) {
if (K9.DEBUG) {
Timber.v(me, "Exception loading attachment");
}
Timber.v(me, "Exception loading attachment");
for (MessagingListener l : getListeners(listener)) {
l.loadAttachmentFailed(account, message, part, me.getMessage());
@ -2768,9 +2685,7 @@ public class MessagingController {
localFolder = localStore.getFolder(
account.getOutboxFolderName());
if (!localFolder.exists()) {
if (K9.DEBUG) {
Timber.v("Outbox does not exist");
}
Timber.v("Outbox does not exist");
return;
}
for (MessagingListener l : getListeners()) {
@ -2792,10 +2707,8 @@ public class MessagingController {
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.BODY);
if (K9.DEBUG) {
Timber.i("Scanning folder '%s' (%d) for messages to send",
account.getOutboxFolderName(), localFolder.getId());
}
Timber.i("Scanning folder '%s' (%d) for messages to send",
account.getOutboxFolderName(), localFolder.getId());
Transport transport = transportProvider.getTransport(K9.app, account);
@ -2810,9 +2723,8 @@ public class MessagingController {
if (oldCount != null) {
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) {
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);
if (K9.DEBUG) {
Timber.i("Sending message with UID %s", message.getUid());
}
Timber.i("Sending message with UID %s", message.getUid());
transport.sendMessage(message);
message.setFlag(Flag.X_SEND_IN_PROGRESS, false);
message.setFlag(Flag.SEEN, true);
progress++;
@ -2889,9 +2801,8 @@ public class MessagingController {
Timber.i("Failed to send pending messages because storage is not available - trying again later.");
throw new UnavailableAccountException(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()) {
l.sendPendingMessagesFailed(account);
}
@ -2908,23 +2819,15 @@ public class MessagingController {
private void moveOrDeleteSentMessage(Account account, LocalStore localStore,
LocalFolder localFolder, LocalMessage message) throws MessagingException {
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);
} else {
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);
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());
queuePendingCommand(account, command);
@ -3233,10 +3136,8 @@ public class MessagingController {
origUidMap.put(message.getUid(), message);
}
if (K9.DEBUG) {
Timber.i("moveOrCopyMessageSynchronous: source folder = %s, %d messages, " +
"destination folder = %s, isCopy = %s", srcFolder, messages.size(), destFolder, isCopy);
}
Timber.i("moveOrCopyMessageSynchronous: source folder = %s, %d messages, destination folder = %s, " +
"isCopy = %s", srcFolder, messages.size(), destFolder, isCopy);
Map<String, String> uidMap;
@ -3438,9 +3339,7 @@ public class MessagingController {
localFolder = localStore.getFolder(folder);
Map<String, String> uidMap = null;
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);
} else {
@ -3449,9 +3348,7 @@ public class MessagingController {
localTrashFolder.create(Folder.FolderType.HOLDS_MESSAGES);
}
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);
@ -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())) {
for (Message message : messages) {
@ -3489,9 +3384,7 @@ public class MessagingController {
queueSetFlag(account, folder, true, Flag.SEEN, uids);
processPendingCommands(account);
} 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);
@ -3629,10 +3522,8 @@ public class MessagingController {
}
public void sendAlternate(Context context, Account account, LocalMessage message) {
if (K9.DEBUG) {
Timber.d("Got message %s:%s:%s for sendAlternate",
account.getDescription(), message.getFolder(), message.getUid());
}
Timber.d("Got message %s:%s:%s for sendAlternate",
account.getDescription(), message.getFolder(), message.getUid());
Intent msg = new Intent(Intent.ACTION_SEND);
String quotedText = null;
@ -3700,9 +3591,8 @@ public class MessagingController {
public void run() {
try {
if (K9.DEBUG) {
Timber.i("Starting mail check");
}
Timber.i("Starting mail check");
Preferences prefs = Preferences.getPreferences(context);
Collection<Account> accounts;
@ -3725,9 +3615,7 @@ public class MessagingController {
@Override
public void run() {
if (K9.DEBUG) {
Timber.i("Finished mail sync");
}
Timber.i("Finished mail sync");
if (wakeLock != null) {
wakeLock.release();
@ -3748,22 +3636,16 @@ public class MessagingController {
final boolean ignoreLastCheckedTime,
final MessagingListener listener) {
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;
}
final long accountInterval = account.getAutomaticCheckIntervalMinutes() * 60 * 1000;
if (!ignoreLastCheckedTime && accountInterval <= 0) {
if (K9.DEBUG) {
Timber.i("Skipping synchronizing account %s", account.getDescription());
}
Timber.i("Skipping synchronizing account %s", account.getDescription());
return;
}
if (K9.DEBUG) {
Timber.i("Synchronizing account %s", account.getDescription());
}
Timber.i("Synchronizing account %s", account.getDescription());
account.setRingNotified(false);
@ -3812,9 +3694,8 @@ public class MessagingController {
putBackground("clear notification flag for " + account.getDescription(), null, new Runnable() {
@Override
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);
try {
AccountStats stats = account.getStats(context);
@ -3840,20 +3721,14 @@ public class MessagingController {
final long accountInterval,
final MessagingListener listener) {
Timber.v("Folder %s was last synced @ %tc", folder.getName(), folder.getLastChecked());
if (K9.DEBUG) {
Timber.v("Folder %s was last synced @ %tc", folder.getName(), folder.getLastChecked());
}
if (!ignoreLastCheckedTime && folder.getLastChecked() >
(System.currentTimeMillis() - accountInterval)) {
if (K9.DEBUG) {
Timber.v("Not syncing folder %s, previously synced @ %tc which would be too recent for the account " +
"period", folder.getName(), folder.getLastChecked());
}
if (!ignoreLastCheckedTime && folder.getLastChecked() > System.currentTimeMillis() - accountInterval) {
Timber.v("Not syncing folder %s, previously synced @ %tc which would be too recent for the account " +
"period", folder.getName(), folder.getLastChecked());
return;
}
putBackground("sync" + folder.getName(), null, new Runnable() {
@Override
public void run() {
@ -3867,11 +3742,9 @@ public class MessagingController {
if (!ignoreLastCheckedTime && tLocalFolder.getLastChecked() >
(System.currentTimeMillis() - accountInterval)) {
if (K9.DEBUG) {
Timber.v("Not running Command for folder %s, previously synced @ %tc which would " +
"be too recent for the account period",
folder.getName(), folder.getLastChecked());
}
Timber.v("Not running Command for folder %s, previously synced @ %tc which would " +
"be too recent for the account period",
folder.getName(), folder.getLastChecked());
return;
}
showFetchingMailNotificationIfNecessary(account, folder);
@ -3881,7 +3754,6 @@ public class MessagingController {
clearFetchingMailNotificationIfNecessary(account);
}
} catch (Exception e) {
Timber.e(e, "Exception while processing folder %s:%s",
account.getDescription(), folder.getName());
addErrorMessage(account, null, e);
@ -4040,10 +3912,8 @@ public class MessagingController {
try {
Integer messageUid = Integer.parseInt(message.getUid());
if (messageUid <= localFolder.getLastUid()) {
if (K9.DEBUG) {
Timber.d("Message uid is %s, max message uid is %s. Skipping notification.",
messageUid, localFolder.getLastUid());
}
Timber.d("Message uid is %s, max message uid is %s. Skipping notification.",
messageUid, localFolder.getLastUid());
return false;
}
} catch (NumberFormatException e) {
@ -4230,9 +4100,8 @@ public class MessagingController {
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());
}
@ -4242,10 +4111,8 @@ public class MessagingController {
int maxPushFolders = account.getMaxPushFolders();
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",
account.getDescription(), names.size(), maxPushFolders);
}
Timber.i("Count of folders to push for account %s is %d, greater than limit of %d, truncating",
account.getDescription(), names.size(), maxPushFolders);
names = names.subList(0, maxPushFolders);
}
@ -4253,9 +4120,7 @@ public class MessagingController {
try {
Store store = account.getRemoteStore();
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;
}
@ -4273,9 +4138,7 @@ public class MessagingController {
return true;
} 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;
}
@ -4286,9 +4149,7 @@ public class MessagingController {
}
public void stopAllPushing() {
if (K9.DEBUG) {
Timber.i("Stopping all pushers");
}
Timber.i("Stopping all pushers");
Iterator<Pusher> iter = pushers.values().iterator();
while (iter.hasNext()) {
@ -4300,10 +4161,8 @@ public class MessagingController {
public void messagesArrived(final Account account, final Folder remoteFolder, final List<Message> messages,
final boolean flagSyncOnly) {
if (K9.DEBUG) {
Timber.i("Got new pushed email messages for account %s, folder %s",
account.getDescription(), remoteFolder.getName());
}
Timber.i("Got new pushed email messages for account %s, folder %s",
account.getDescription(), remoteFolder.getName());
final CountDownLatch latch = new CountDownLatch(1);
putBackground("Push messageArrived of account " + account.getDescription()
@ -4324,9 +4183,7 @@ public class MessagingController {
localFolder.setLastPush(System.currentTimeMillis());
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) {
notificationController.clearNewMailNotifications(account);
@ -4360,9 +4217,8 @@ public class MessagingController {
} catch (Exception e) {
Timber.e(e, "Interrupted while awaiting latch release");
}
if (K9.DEBUG) {
Timber.i("MessagingController.messagesArrivedLatch released");
}
Timber.i("MessagingController.messagesArrivedLatch released");
}
public void systemStatusChanged() {

View file

@ -40,8 +40,8 @@ public class MessagingControllerPushReceiver implements PushReceiver {
}
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);
controller.synchronizeMailbox(account, folder.getName(), new SimpleMessagingListener() {
@Override
@ -57,12 +57,11 @@ public class MessagingControllerPushReceiver implements PushReceiver {
}
}, 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 {
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) {
Timber.e(e, "Interrupted while awaiting latch release");
}

View file

@ -108,8 +108,7 @@ public class ConfirmationDialogFragment extends DialogFragment implements OnClic
try {
mListener = (ConfirmationDialogFragmentListener) activity;
} 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()) {
String uriScheme = imgMatches.group(1);
if (uriScheme.equals("http") || uriScheme.equals("https")) {
if (K9.DEBUG) {
Timber.d("External images found");
}
Timber.d("External images found");
return true;
}
}
if (K9.DEBUG) {
Timber.d("No external images.");
}
Timber.d("No external images.");
return false;
}

View file

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

View file

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

View file

@ -75,10 +75,7 @@ public class LockableDatabase {
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 {
lockWrite();
@ -98,10 +95,7 @@ public class LockableDatabase {
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 {
openOrCreateDataspace();
@ -465,8 +459,7 @@ public class LockableDatabase {
try {
mDb.close();
} 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();
try {
@ -475,20 +468,19 @@ public class LockableDatabase {
for (File attachment : attachments) {
if (attachment.exists()) {
boolean attachmentWasDeleted = attachment.delete();
if (!attachmentWasDeleted && K9.DEBUG) {
if (!attachmentWasDeleted) {
Timber.d("Attachment was not deleted!");
}
}
}
if (attachmentDirectory.exists()) {
boolean attachmentDirectoryWasDeleted = attachmentDirectory.delete();
if (!attachmentDirectoryWasDeleted && K9.DEBUG) {
if (!attachmentDirectoryWasDeleted) {
Timber.d("Attachment directory was not deleted!");
}
}
} 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 {
deleteDatabase(storageManager.getDatabase(uUid, mStorageProviderId));

View file

@ -450,14 +450,13 @@ class MigrationTo51 {
private static MimeStructureState insertMimeAttachmentPart(SQLiteDatabase db, File attachmentDirOld,
File attachmentDirNew, MimeStructureState structureState, long id, int size, String name, String mimeType,
String storeData, String contentUriString, String contentId, String contentDisposition) {
if (K9.DEBUG) {
Timber.d("processing attachment %d, %s, %s, %s, %s",
id,
name,
mimeType,
storeData,
contentUriString);
}
Timber.d("processing attachment %d, %s, %s, %s, %s",
id,
name,
mimeType,
storeData,
contentUriString);
if (contentDisposition == null) {
contentDisposition = "attachment";
@ -501,7 +500,7 @@ class MigrationTo51 {
} else {
attachmentFileToMove = null;
}
if (K9.DEBUG && attachmentFileToMove == null) {
if (attachmentFileToMove == null) {
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();
if (K9.DEBUG) {
Timber.d("Generated identity: %s", k9identity);
}
Timber.d("Generated identity: %s", k9identity);
return k9identity;
}

View file

@ -24,9 +24,7 @@ public class IdentityHeaderParser {
public static Map<IdentityField, String> parse(final String identityString) {
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) {
return identity;
@ -44,9 +42,7 @@ public class IdentityHeaderParser {
}
}
if (K9.DEBUG) {
Timber.d("Decoded identity: %s", identity.toString());
}
Timber.d("Decoded identity: %s", identity);
// Sanity check our Integers so that recipients of this result don't have to.
for (IdentityField key : IdentityField.getIntegerFields()) {
@ -61,9 +57,8 @@ public class IdentityHeaderParser {
} else {
// 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);
// 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.
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/html");
if (part != null) {
if (K9.DEBUG) {
Timber.d("getBodyTextFromMessage: HTML requested, HTML found.");
}
Timber.d("getBodyTextFromMessage: HTML requested, HTML found.");
return MessageExtractor.getTextFromPart(part);
}
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/plain");
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);
return HtmlConverter.textToHtml(text);
}
@ -40,17 +36,13 @@ public class BodyTextExtractor {
// Text takes precedence, then html.
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/plain");
if (part != null) {
if (K9.DEBUG) {
Timber.d("getBodyTextFromMessage: Text requested, text found.");
}
Timber.d("getBodyTextFromMessage: Text requested, text found.");
return MessageExtractor.getTextFromPart(part);
}
part = MimeUtility.findFirstPartByMimeType(messagePart, "text/html");
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);
return HtmlConverter.htmlToText(text);
}

View file

@ -149,9 +149,7 @@ public class HtmlQuoteCreator {
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.
// 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;
}
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.
// 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
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);
Preferences preferences = Preferences.getPreferences(this);
@ -147,9 +145,7 @@ public class NotificationActionService extends CoreService {
} else if (ACTION_SPAM.equals(action)) {
markMessageAsSpam(intent, account, controller);
} else if (ACTION_DISMISS.equals(action)) {
if (K9.DEBUG) {
Timber.i("Notification dismissed");
}
Timber.i("Notification dismissed");
}
cancelNotifications(intent, account, controller);
@ -158,9 +154,7 @@ public class NotificationActionService extends CoreService {
}
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<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
@ -172,9 +166,7 @@ public class NotificationActionService extends CoreService {
}
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<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings);
@ -182,9 +174,7 @@ public class NotificationActionService extends CoreService {
}
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();
if (archiveFolderName == null ||
@ -205,9 +195,7 @@ public class NotificationActionService extends CoreService {
}
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);
MessageReference messageReference = MessageReference.parse(messageReferenceString);

View file

@ -177,9 +177,7 @@ public class Settings {
validatedSettingsMutable.remove(settingName);
deletedSettingsMutable.add(settingName);
if (K9.DEBUG) {
Timber.v("Removed setting \"%s\"", settingName);
}
Timber.v("Removed setting \"%s\"", settingName);
}
/**
@ -211,9 +209,7 @@ public class Settings {
serializedSettings.put(settingName, stringValue);
} 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);
}
}

View file

@ -187,10 +187,7 @@ public class SettingsExporter {
"This shouldn't happen!", key, valueString);
}
} 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);
}
}

View file

@ -183,14 +183,10 @@ public class SettingsImporter {
Timber.w("Was asked to import global settings but none found.");
}
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;
} 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) {
Timber.e(e, "Exception while importing global settings");
@ -209,10 +205,8 @@ public class SettingsImporter {
imported.contentVersion, account, overwrite);
if (editor.commit()) {
if (K9.DEBUG) {
Timber.v("Committed settings for account \"%s\" to the settings database.",
importResult.imported.name);
}
Timber.v("Committed settings for account \"%s\" to the settings database.",
importResult.imported.name);
// Add UUID of the account we just imported to the list of
// account UUIDs
@ -236,17 +230,15 @@ public class SettingsImporter {
importedAccounts.add(importResult);
} else {
if (K9.DEBUG) {
Timber.w("Error while committing settings for account \"%s\" to the settings " +
"database.", importResult.original.name);
}
Timber.w("Error while committing settings for account \"%s\" to the settings " +
"database.", importResult.original.name);
erroneousAccounts.add(importResult.original);
}
} catch (InvalidSettingValueException e) {
if (K9.DEBUG) {
Timber.e(e, "Encountered invalid setting while importing account \"%s\"",
account.name);
}
Timber.e(e, "Encountered invalid setting while importing account \"%s\"",
account.name);
erroneousAccounts.add(new AccountDescription(account.name, account.uuid));
} catch (Exception e) {
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) {
Storage tmpStorage = storages.get(context);
if (tmpStorage != null) {
if (K9.DEBUG) {
Timber.d("Returning already existing Storage");
}
Timber.d("Returning already existing Storage");
return tmpStorage;
} else {
if (K9.DEBUG) {
Timber.d("Creating provisional storage");
}
Timber.d("Creating provisional storage");
tmpStorage = new Storage(context);
Storage oldStorage = storages.putIfAbsent(context, tmpStorage);
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;
} else {
if (K9.DEBUG) {
Timber.d("Returning the Storage we created");
}
Timber.d("Returning the Storage we created");
return tmpStorage;
}
}
@ -177,9 +169,7 @@ public class Storage {
while (cursor.moveToNext()) {
String key = cursor.getString(0);
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);
}
} finally {
@ -335,9 +325,7 @@ public class Storage {
if (cursor.moveToNext()) {
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 {
Utility.closeQuietly(cursor);

View file

@ -29,14 +29,10 @@ public class StorageEditor {
String key = entry.getKey();
Object value = entry.getValue();
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);
} else {
if (K9.DEBUG) {
Timber.d("Skipping copying key '%s', value '%s'", key, value);
}
Timber.d("Skipping copying key '%s', value '%s'", key, value);
}
}
}

View file

@ -101,9 +101,7 @@ public class AttachmentProvider extends ContentProvider {
}
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;
}

View file

@ -167,9 +167,7 @@ public class AttachmentTempFileProvider extends FileProvider {
return;
}
if (K9.DEBUG) {
Timber.d("Unregistering temp file cleanup receiver");
}
Timber.d("Unregistering temp file cleanup receiver");
context.unregisterReceiver(cleanupReceiver);
cleanupReceiver = null;
}
@ -180,9 +178,8 @@ public class AttachmentTempFileProvider extends FileProvider {
if (cleanupReceiver != null) {
return;
}
if (K9.DEBUG) {
Timber.d("Registering temp file cleanup receiver");
}
Timber.d("Registering temp file cleanup receiver");
cleanupReceiver = new AttachmentTempFileProviderCleanupReceiver();
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!");
}
if (K9.DEBUG) {
Timber.d("Cleaning up temp files");
}
Timber.d("Cleaning up temp files");
boolean allFilesDeleted = deleteOldTemporaryFiles(context);
if (allFilesDeleted) {

View file

@ -132,7 +132,7 @@ public class DecryptedFileProvider extends FileProvider {
InputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pfd);
decodedInputStream = new QuotedPrintableInputStream(inputStream);
} else { // no or unknown encoding
if (K9.DEBUG && !TextUtils.isEmpty(encoding)) {
if (!TextUtils.isEmpty(encoding)) {
Timber.e("unsupported encoding, returning raw stream");
}
return pfd;
@ -173,9 +173,7 @@ public class DecryptedFileProvider extends FileProvider {
return;
}
if (K9.DEBUG) {
Timber.d("Unregistering temp file cleanup receiver");
}
Timber.d("Unregistering temp file cleanup receiver");
context.unregisterReceiver(cleanupReceiver);
cleanupReceiver = null;
}
@ -186,9 +184,8 @@ public class DecryptedFileProvider extends FileProvider {
if (cleanupReceiver != null) {
return;
}
if (K9.DEBUG) {
Timber.d("Registering temp file cleanup receiver");
}
Timber.d("Registering temp file cleanup receiver");
cleanupReceiver = new DecryptedFileProviderCleanupReceiver();
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!");
}
if (K9.DEBUG) {
Timber.d("Cleaning up temp files");
}
Timber.d("Cleaning up temp files");
boolean allFilesDeleted = deleteOldTemporaryFiles(context);
if (allFilesDeleted) {

View file

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

View file

@ -99,9 +99,7 @@ public class UnreadWidgetProvider extends AppWidgetProvider {
unreadCount = stats.unreadMessageCount;
}
} catch (Exception e) {
if (K9.DEBUG) {
Timber.e(e, "Error getting widget configuration");
}
Timber.e(e, "Error getting widget configuration");
}
if (unreadCount <= 0) {

View file

@ -25,8 +25,7 @@ public class BootReceiver extends CoreReceiver {
@Override
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();
if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
@ -50,16 +49,14 @@ public class BootReceiver extends CoreReceiver {
} else if (FIRE_INTENT.equals(action)) {
Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT);
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);
tmpWakeLockId = null;
context.startService(alarmedIntent);
} else if (SCHEDULE_INTENT.equals(action)) {
long atTime = intent.getLongExtra(AT_TIME, -1);
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);
K9AlarmManager alarmMgr = K9AlarmManager.getAlarmManager(context);
@ -67,8 +64,7 @@ public class BootReceiver extends CoreReceiver {
alarmMgr.set(AlarmManager.RTC_WAKEUP, atTime, pi);
} else if (CANCEL_INTENT.equals(action)) {
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);
@ -94,8 +90,8 @@ public class BootReceiver extends CoreReceiver {
}
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();
i.setClass(context, BootReceiver.class);
i.setAction(SCHEDULE_INTENT);
@ -105,8 +101,8 @@ public class BootReceiver extends CoreReceiver {
}
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();
i.setClass(context, BootReceiver.class);
i.setAction(CANCEL_INTENT);

View file

@ -30,8 +30,7 @@ public class CoreReceiver extends BroadcastReceiver {
wakeLock.acquire(K9.BOOT_RECEIVER_WAKE_LOCK_TIMEOUT);
Integer tmpWakeLockId = wakeLockSeq.getAndIncrement();
wakeLocks.put(tmpWakeLockId, wakeLock);
if (K9.DEBUG)
Timber.v("CoreReceiver Created wakeLock %d", tmpWakeLockId);
Timber.v("CoreReceiver Created wakeLock %d", tmpWakeLockId);
return tmpWakeLockId;
}
@ -39,8 +38,7 @@ public class CoreReceiver extends BroadcastReceiver {
if (wakeLockId != null) {
TracingWakeLock wl = wakeLocks.remove(wakeLockId);
if (wl != null) {
if (K9.DEBUG)
Timber.v("CoreReceiver Releasing wakeLock %d", wakeLockId);
Timber.v("CoreReceiver Releasing wakeLock %d", wakeLockId);
wl.release();
} else {
Timber.w("BootReceiver WakeLock %d doesn't exist", wakeLockId);
@ -52,13 +50,12 @@ public class CoreReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Integer tmpWakeLockId = CoreReceiver.getWakeLock(context);
try {
if (K9.DEBUG)
Timber.i("CoreReceiver.onReceive %s", intent);
Timber.i("CoreReceiver.onReceive %s", intent);
if (CoreReceiver.WAKE_LOCK_RELEASE.equals(intent.getAction())) {
Integer wakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1);
if (wakeLockId != -1) {
if (K9.DEBUG)
Timber.v("CoreReceiver Release wakeLock %d", wakeLockId);
Timber.v("CoreReceiver Release wakeLock %d", wakeLockId);
CoreReceiver.releaseWakeLock(wakeLockId);
}
} else {
@ -74,8 +71,8 @@ public class CoreReceiver extends BroadcastReceiver {
}
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();
i.setClass(context, CoreReceiver.class);
i.setAction(WAKE_LOCK_RELEASE);

View file

@ -190,9 +190,7 @@ public abstract class CoreService extends Service {
@Override
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
}
@ -217,9 +215,7 @@ public abstract class CoreService extends Service {
TracingWakeLock wakeLock = acquireWakeLock(this, "CoreService onStart",
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.
int wakeLockId = intent.getIntExtra(BootReceiver.WAKE_LOCK_ID, -1);
@ -231,18 +227,14 @@ public abstract class CoreService extends Service {
// release it.
int coreWakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -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
TracingWakeLock coreWakeLock = sWakeLocks.remove(coreWakeLockId);
// Release wake lock
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();
}
}
@ -305,10 +297,8 @@ public abstract class CoreService extends Service {
// Get the sync status
boolean oldIsSyncDisabled = MailService.isSyncDisabled();
if (K9.DEBUG) {
Timber.d("CoreService (%s) running Runnable %d with startId %d",
className, runner.hashCode(), startId);
}
Timber.d("CoreService (%s) running Runnable %d with startId %d",
className, runner.hashCode(), startId);
// Run the supplied code
runner.run();
@ -321,10 +311,9 @@ public abstract class CoreService extends Service {
} finally {
// Making absolutely sure stopSelf() will be called
try {
if (K9.DEBUG) {
Timber.d("CoreService (%s) completed Runnable %d with startId %d",
className, runner.hashCode(), startId);
}
Timber.d("CoreService (%s) completed Runnable %d with startId %d",
className, runner.hashCode(), startId);
wakeLock.release();
} finally {
if (autoShutdown && startId != null) {
@ -345,10 +334,7 @@ public abstract class CoreService extends Service {
serviceShutdownScheduled = startId != null;
}
} 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 {
mThreadPool.execute(myRunner);
@ -397,9 +383,7 @@ public abstract class CoreService extends Service {
*/
@Override
public void onDestroy() {
if (K9.DEBUG) {
Timber.i("CoreService: %s.onDestroy()", className);
}
Timber.i("CoreService: %s.onDestroy()", className);
// Shut down thread pool
mShutdown = true;

View file

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

View file

@ -83,8 +83,7 @@ public class MailService extends CoreService {
@Override
public void onCreate() {
super.onCreate();
if (K9.DEBUG)
Timber.v("***** MailService *****: onCreate");
Timber.v("***** MailService *****: onCreate");
}
@Override
@ -114,41 +113,34 @@ public class MailService extends CoreService {
syncNoConnectivity = !hasConnectivity;
syncBlocked = !(doBackground && hasConnectivity);
if (K9.DEBUG)
Timber.i("MailService.onStart(%s, %d), hasConnectivity = %s, doBackground = %s",
intent, startId, hasConnectivity, doBackground);
Timber.i("MailService.onStart(%s, %d), hasConnectivity = %s, doBackground = %s",
intent, startId, hasConnectivity, doBackground);
// MessagingController.getInstance(getApplication()).addListener(mListener);
if (ACTION_CHECK_MAIL.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("***** MailService *****: checking mail");
Timber.i("***** MailService *****: checking mail");
if (hasConnectivity && doBackground) {
PollService.startService(this);
}
reschedulePollInBackground(hasConnectivity, doBackground, startId, false);
} else if (ACTION_CANCEL.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.v("***** MailService *****: cancel");
Timber.v("***** MailService *****: cancel");
cancel();
} else if (ACTION_RESET.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.v("***** MailService *****: reschedule");
Timber.v("***** MailService *****: reschedule");
rescheduleAllInBackground(hasConnectivity, doBackground, startId);
} 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);
} 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);
} else if (ACTION_REFRESH_PUSHERS.equals(intent.getAction())) {
refreshPushersInBackground(hasConnectivity, doBackground, startId);
} else if (CONNECTIVITY_CHANGE.equals(intent.getAction())) {
rescheduleAllInBackground(hasConnectivity, doBackground, startId);
if (K9.DEBUG)
Timber.i("Got connectivity action with hasConnectivity = %s, doBackground = %s",
hasConnectivity, doBackground);
Timber.i("Got connectivity action with hasConnectivity = %s, doBackground = %s",
hasConnectivity, doBackground);
} else if (CANCEL_CONNECTIVITY_NOTICE.equals(intent.getAction())) {
/* do nothing */
}
@ -157,16 +149,14 @@ public class MailService extends CoreService {
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;
}
@Override
public void onDestroy() {
if (K9.DEBUG)
Timber.v("***** MailService *****: onDestroy()");
Timber.v("***** MailService *****: onDestroy()");
super.onDestroy();
// MessagingController.getInstance(getApplication()).removeListener(mListener);
}
@ -182,8 +172,8 @@ public class MailService extends CoreService {
public static void saveLastCheckEnd(Context context) {
long lastCheckEnd = System.currentTimeMillis();
if (K9.DEBUG)
Timber.i("Saving lastCheckEnd = %tc", lastCheckEnd);
Timber.i("Saving lastCheckEnd = %tc", lastCheckEnd);
Preferences prefs = Preferences.getPreferences(context);
Storage storage = prefs.getStorage();
StorageEditor editor = storage.edit();
@ -240,9 +230,7 @@ public class MailService extends CoreService {
boolean considerLastCheckEnd) {
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;
cancel();
@ -277,9 +265,7 @@ public class MailService extends CoreService {
editor.commit();
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;
pollingRequested = false;
@ -290,22 +276,17 @@ public class MailService extends CoreService {
!considerLastCheckEnd ? System.currentTimeMillis() : lastCheckEnd);
long nextTime = base + delay;
if (K9.DEBUG) {
Timber.i("previousInterval = %d, shortestInterval = %d, lastCheckEnd = %tc, considerLastCheckEnd = %tc",
previousInterval,
shortestInterval,
lastCheckEnd,
considerLastCheckEnd);
}
Timber.i("previousInterval = %d, shortestInterval = %d, lastCheckEnd = %tc, considerLastCheckEnd = %tc",
previousInterval,
shortestInterval,
lastCheckEnd,
considerLastCheckEnd);
nextCheck = nextTime;
pollingRequested = true;
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) {
// I once got a NullPointerException deep in new Date();
Timber.e(e, "Exception while logging");
@ -343,17 +324,12 @@ public class MailService extends CoreService {
}
private void reschedulePushers(boolean hasConnectivity, boolean doBackground) {
if (K9.DEBUG) {
Timber.i("Rescheduling pushers");
}
Timber.i("Rescheduling pushers");
stopPushers();
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;
}
@ -365,8 +341,8 @@ public class MailService extends CoreService {
private void setupPushers() {
boolean pushing = false;
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())) {
pushing |= MessagingController.getInstance(getApplication()).setupPushing(account);
} else {
@ -382,39 +358,34 @@ public class MailService extends CoreService {
private void refreshPushers() {
try {
long nowTime = System.currentTimeMillis();
if (K9.DEBUG)
Timber.i("Refreshing pushers");
Timber.i("Refreshing pushers");
Collection<Pusher> pushers = MessagingController.getInstance(getApplication()).getPushers();
for (Pusher pusher : pushers) {
long lastRefresh = pusher.getLastRefresh();
int refreshInterval = pusher.getRefreshInterval();
long sinceLast = nowTime - lastRefresh;
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, " +
"sinceLast = %d",
lastRefresh,
refreshInterval,
nowTime,
sinceLast);
}
Timber.d("PUSHREFRESH: refreshing lastRefresh = %d, interval = %d, nowTime = %d, " +
"sinceLast = %d",
lastRefresh,
refreshInterval,
nowTime,
sinceLast);
pusher.refresh();
pusher.setLastRefresh(nowTime);
} else {
if (K9.DEBUG) {
Timber.d("PUSHREFRESH: NOT refreshing lastRefresh = %d, interval = %d, nowTime = %d, " +
"sinceLast = %d",
lastRefresh,
refreshInterval,
nowTime,
sinceLast);
}
Timber.d("PUSHREFRESH: NOT refreshing lastRefresh = %d, interval = %d, nowTime = %d, " +
"sinceLast = %d",
lastRefresh,
refreshInterval,
nowTime,
sinceLast);
}
}
// 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);
@ -433,13 +404,13 @@ public class MailService extends CoreService {
minInterval = interval;
}
}
if (K9.DEBUG) {
Timber.v("Pusher refresh interval = %d", minInterval);
}
Timber.v("Pusher refresh interval = %d", minInterval);
if (minInterval > 0) {
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);
i.setAction(ACTION_REFRESH_PUSHERS);
BootReceiver.scheduleIntent(MailService.this, nextTime, i);

View file

@ -45,27 +45,23 @@ public class PollService extends CoreService {
@Override
public int startService(Intent intent, int startId) {
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());
Listener listener = (Listener)controller.getCheckMailListener();
if (listener == null) {
if (K9.DEBUG)
Timber.i("***** PollService *****: starting new check");
Timber.i("***** PollService *****: starting new check");
mListener.setStartId(startId);
mListener.wakeLockAcquire();
controller.setCheckMailListener(mListener);
controller.checkMail(this, null, false, false, mListener);
} else {
if (K9.DEBUG)
Timber.i("***** PollService *****: renewing WakeLock");
Timber.i("***** PollService *****: renewing WakeLock");
listener.setStartId(startId);
listener.wakeLockAcquire();
}
} else if (STOP_SERVICE.equals(intent.getAction())) {
if (K9.DEBUG)
Timber.i("PollService stopping");
Timber.i("PollService stopping");
stopSelf();
}
@ -131,17 +127,14 @@ public class PollService extends CoreService {
MailService.actionReschedulePoll(PollService.this, null);
wakeLockRelease();
if (K9.DEBUG)
Timber.i("PollService stopping with startId = %d", startId);
Timber.i("PollService stopping with startId = %d", startId);
stopSelf(startId);
}
@Override
public void checkMailFinished(Context context, Account account) {
if (K9.DEBUG)
Timber.v("***** PollService *****: checkMailFinished");
Timber.v("***** PollService *****: checkMailFinished");
release();
}
public int getStartId() {

View file

@ -30,11 +30,9 @@ public class PushService extends CoreService {
public int startService(Intent intent, int startId) {
int startFlag = START_STICKY;
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())) {
if (K9.DEBUG)
Timber.i("PushService stopping with startId = %d", startId);
Timber.i("PushService stopping with startId = %d", startId);
stopSelf(startId);
startFlag = START_NOT_STICKY;
}

View file

@ -18,8 +18,7 @@ import static com.fsck.k9.remotecontrol.K9RemoteControl.*;
public class RemoteControlReceiver extends CoreReceiver {
@Override
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())) {
RemoteControlService.set(context, intent, tmpWakeLockId);

View file

@ -37,22 +37,18 @@ public class RemoteControlService extends CoreService {
@Override
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);
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);
}
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);
} 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() {
public void run() {
try {
@ -60,21 +56,20 @@ public class RemoteControlService extends CoreService {
boolean needsPushRestart = false;
String uuid = intent.getStringExtra(K9_ACCOUNT_UUID);
boolean allAccounts = intent.getBooleanExtra(K9_ALL_ACCOUNTS, false);
if (K9.DEBUG) {
if (allAccounts) {
Timber.i("RemoteControlService changing settings for all accounts");
} else {
Timber.i("RemoteControlService changing settings for account with UUID %s", uuid);
}
if (allAccounts) {
Timber.i("RemoteControlService changing settings for all accounts");
} else {
Timber.i("RemoteControlService changing settings for account with UUID %s", uuid);
}
List<Account> accounts = preferences.getAccounts();
for (Account account : accounts) {
//warning: account may not be isAvailable()
if (allAccounts || account.getUuid().equals(uuid)) {
if (K9.DEBUG)
Timber.i("RemoteControlService changing settings for account %s",
account.getDescription());
Timber.i("RemoteControlService changing settings for account %s",
account.getDescription());
String notificationEnabled = intent.getStringExtra(K9_NOTIFICATION_ENABLED);
String ringEnabled = intent.getStringExtra(K9_RING_ENABLED);
@ -110,8 +105,8 @@ public class RemoteControlService extends CoreService {
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);
if (K9RemoteControl.K9_BACKGROUND_OPERATIONS_ALWAYS.equals(backgroundOps)

View file

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

View file

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

View file

@ -23,9 +23,7 @@ public class StorageReceiver extends BroadcastReceiver {
return;
}
if (K9.DEBUG) {
Timber.v("StorageReceiver: %s", intent);
}
Timber.v("StorageReceiver: %s", intent);
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.
quotedTextFormat = SimpleMessageFormat.HTML;
String text = MessageExtractor.getTextFromPart(part);
if (K9.DEBUG) {
Timber.d("Loading message with offset %d, length %d. Text length is %d.",
bodyOffset, bodyLength, text.length());
}
Timber.d("Loading message with offset %d, length %d. Text length is %d.",
bodyOffset, bodyLength, text.length());
if (bodyOffset + bodyLength > text.length()) {
// The draft was edited outside of K-9 Mail?
@ -319,10 +318,9 @@ public class QuotedMessagePresenter {
}
String messageText = MessageExtractor.getTextFromPart(textPart);
if (K9.DEBUG) {
Timber.d("Loading message with offset %d, length %d. Text length is %d.",
bodyOffset, bodyLength, messageText.length());
}
Timber.d("Loading message with offset %d, length %d. Text length is %d.",
bodyOffset, bodyLength, messageText.length());
// 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.

View file

@ -470,9 +470,7 @@ public class MessageCryptoHelper {
private void handleCryptoOperationResult(MimeBodyPart outputPart) {
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) {
case INVALID_OPENPGP_RESULT_CODE: {
@ -505,9 +503,7 @@ public class MessageCryptoHelper {
private void handleCryptoOperationError() {
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);
}

View file

@ -211,9 +211,7 @@ public class AttachmentController {
writeAttachmentToStorage(tempFile);
viewIntent = createViewIntentForFileUri(resolvedIntentInfo.getMimeType(), Uri.fromFile(tempFile));
} 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);
}
} else {
@ -353,9 +351,7 @@ public class AttachmentController {
File directory = params[0];
return saveAttachmentWithUniqueFileName(directory);
} catch (IOException e) {
if (K9.DEBUG) {
Timber.e(e, "Error saving attachment");
}
Timber.e(e, "Error saving attachment");
return null;
}
}

View file

@ -208,9 +208,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
private void displayMessage(MessageReference 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());
messageLoaderHelper.asyncStartOrResumeLoadingMessage(messageReference, null);

View file

@ -102,8 +102,7 @@ public class ClientCertificateSpinner extends LinearLayout {
KeyChain.choosePrivateKeyAlias(mActivity, new KeyChainAliasCallback() {
@Override
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);
}

View file

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