am b3eefca0
: DO NOT MERGE: Fix NPE in Controller and MessagingController.
Merge commit 'b3eefca0e1c7fffe1b015e18050aee6867bfbcdd' into gingerbread-plus-aosp * commit 'b3eefca0e1c7fffe1b015e18050aee6867bfbcdd': DO NOT MERGE: Fix NPE in Controller and MessagingController.
This commit is contained in:
commit
723c21d0b0
@ -405,6 +405,9 @@ public class Controller {
|
|||||||
// for IMAP & POP only, (attempt to) send the message now
|
// for IMAP & POP only, (attempt to) send the message now
|
||||||
final EmailContent.Account account =
|
final EmailContent.Account account =
|
||||||
EmailContent.Account.restoreAccountWithId(mProviderContext, accountId);
|
EmailContent.Account.restoreAccountWithId(mProviderContext, accountId);
|
||||||
|
if (account == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final long sentboxId = findOrCreateMailboxOfType(accountId, Mailbox.TYPE_SENT);
|
final long sentboxId = findOrCreateMailboxOfType(accountId, Mailbox.TYPE_SENT);
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
@ -444,6 +447,9 @@ public class Controller {
|
|||||||
// MessagingController implementation
|
// MessagingController implementation
|
||||||
final EmailContent.Account account =
|
final EmailContent.Account account =
|
||||||
EmailContent.Account.restoreAccountWithId(mProviderContext, accountId);
|
EmailContent.Account.restoreAccountWithId(mProviderContext, accountId);
|
||||||
|
if (account == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final long sentboxId = findOrCreateMailboxOfType(accountId, Mailbox.TYPE_SENT);
|
final long sentboxId = findOrCreateMailboxOfType(accountId, Mailbox.TYPE_SENT);
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
@ -619,6 +625,9 @@ public class Controller {
|
|||||||
|
|
||||||
// 6. Service runs automatically, MessagingController needs a kick
|
// 6. Service runs automatically, MessagingController needs a kick
|
||||||
Account account = Account.restoreAccountWithId(mProviderContext, accountId);
|
Account account = Account.restoreAccountWithId(mProviderContext, accountId);
|
||||||
|
if (account == null) {
|
||||||
|
return; // isMessagingController returns false for null, but let's make it clear.
|
||||||
|
}
|
||||||
if (isMessagingController(account)) {
|
if (isMessagingController(account)) {
|
||||||
final long syncAccountId = accountId;
|
final long syncAccountId = accountId;
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@ -647,7 +656,13 @@ public class Controller {
|
|||||||
|
|
||||||
// Service runs automatically, MessagingController needs a kick
|
// Service runs automatically, MessagingController needs a kick
|
||||||
final Message message = Message.restoreMessageWithId(mProviderContext, messageId);
|
final Message message = Message.restoreMessageWithId(mProviderContext, messageId);
|
||||||
|
if (message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Account account = Account.restoreAccountWithId(mProviderContext, message.mAccountKey);
|
Account account = Account.restoreAccountWithId(mProviderContext, message.mAccountKey);
|
||||||
|
if (account == null) {
|
||||||
|
return; // isMessagingController returns false for null, but let's make it clear.
|
||||||
|
}
|
||||||
if (isMessagingController(account)) {
|
if (isMessagingController(account)) {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
@ -675,7 +690,13 @@ public class Controller {
|
|||||||
|
|
||||||
// Service runs automatically, MessagingController needs a kick
|
// Service runs automatically, MessagingController needs a kick
|
||||||
final Message message = Message.restoreMessageWithId(mProviderContext, messageId);
|
final Message message = Message.restoreMessageWithId(mProviderContext, messageId);
|
||||||
|
if (message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Account account = Account.restoreAccountWithId(mProviderContext, message.mAccountKey);
|
Account account = Account.restoreAccountWithId(mProviderContext, message.mAccountKey);
|
||||||
|
if (account == null) {
|
||||||
|
return; // isMessagingController returns false for null, but let's make it clear.
|
||||||
|
}
|
||||||
if (isMessagingController(account)) {
|
if (isMessagingController(account)) {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
@ -772,6 +793,9 @@ public class Controller {
|
|||||||
private IEmailService getServiceForMessage(long messageId) {
|
private IEmailService getServiceForMessage(long messageId) {
|
||||||
// TODO make this more efficient, caching the account, smaller lookup here, etc.
|
// TODO make this more efficient, caching the account, smaller lookup here, etc.
|
||||||
Message message = Message.restoreMessageWithId(mProviderContext, messageId);
|
Message message = Message.restoreMessageWithId(mProviderContext, messageId);
|
||||||
|
if (message == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return getServiceForAccount(message.mAccountKey);
|
return getServiceForAccount(message.mAccountKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,6 +1094,9 @@ public class MessagingController implements Runnable {
|
|||||||
if (oldMessage != null) {
|
if (oldMessage != null) {
|
||||||
if (mailbox == null || mailbox.mId != oldMessage.mMailboxKey) {
|
if (mailbox == null || mailbox.mId != oldMessage.mMailboxKey) {
|
||||||
mailbox = Mailbox.restoreMailboxWithId(mContext, oldMessage.mMailboxKey);
|
mailbox = Mailbox.restoreMailboxWithId(mContext, oldMessage.mMailboxKey);
|
||||||
|
if (mailbox == null) {
|
||||||
|
continue; // Mailbox removed. Move to the next message.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
deleteFromTrash = mailbox.mType == Mailbox.TYPE_TRASH;
|
deleteFromTrash = mailbox.mType == Mailbox.TYPE_TRASH;
|
||||||
}
|
}
|
||||||
@ -1177,6 +1180,9 @@ public class MessagingController implements Runnable {
|
|||||||
// Load the mailbox if it will be needed
|
// Load the mailbox if it will be needed
|
||||||
if (mailbox == null) {
|
if (mailbox == null) {
|
||||||
mailbox = Mailbox.restoreMailboxWithId(mContext, mailboxId);
|
mailbox = Mailbox.restoreMailboxWithId(mContext, mailboxId);
|
||||||
|
if (mailbox == null) {
|
||||||
|
continue; // Mailbox removed. Move to the next message.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// upsync the message
|
// upsync the message
|
||||||
long id = upsyncs1.getLong(EmailContent.Message.ID_PROJECTION_COLUMN);
|
long id = upsyncs1.getLong(EmailContent.Message.ID_PROJECTION_COLUMN);
|
||||||
@ -1204,6 +1210,9 @@ public class MessagingController implements Runnable {
|
|||||||
// Load the mailbox if it will be needed
|
// Load the mailbox if it will be needed
|
||||||
if (mailbox == null) {
|
if (mailbox == null) {
|
||||||
mailbox = Mailbox.restoreMailboxWithId(mContext, mailboxId);
|
mailbox = Mailbox.restoreMailboxWithId(mContext, mailboxId);
|
||||||
|
if (mailbox == null) {
|
||||||
|
continue; // Mailbox removed. Move to the next message.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// upsync the message
|
// upsync the message
|
||||||
long id = upsyncs2.getLong(EmailContent.Message.ID_PROJECTION_COLUMN);
|
long id = upsyncs2.getLong(EmailContent.Message.ID_PROJECTION_COLUMN);
|
||||||
@ -1264,6 +1273,9 @@ public class MessagingController implements Runnable {
|
|||||||
if (newMessage != null) {
|
if (newMessage != null) {
|
||||||
if (mailbox == null || mailbox.mId != newMessage.mMailboxKey) {
|
if (mailbox == null || mailbox.mId != newMessage.mMailboxKey) {
|
||||||
mailbox = Mailbox.restoreMailboxWithId(mContext, newMessage.mMailboxKey);
|
mailbox = Mailbox.restoreMailboxWithId(mContext, newMessage.mMailboxKey);
|
||||||
|
if (mailbox == null) {
|
||||||
|
continue; // Mailbox removed. Move to the next message.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
changeMoveToTrash = (oldMessage.mMailboxKey != newMessage.mMailboxKey)
|
changeMoveToTrash = (oldMessage.mMailboxKey != newMessage.mMailboxKey)
|
||||||
&& (mailbox.mType == Mailbox.TYPE_TRASH);
|
&& (mailbox.mType == Mailbox.TYPE_TRASH);
|
||||||
|
Loading…
Reference in New Issue
Block a user