Fix NPE sending mail on servers without Outbox folders
* stopPing (in SyncManager) assumes that every mailbox has a serverId
but this is not the case on some servers, in which case we hit an
NPE during a check for the account mailbox
* Check for a null serverId when testing for the account mailbox
Bug: 2606385
Change-Id: Idfa8abd8ef9e2c0a2ac01d0b168a21c934f6fdf3
diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java
index f955489..5eb7b2d 100644
--- a/src/com/android/exchange/SyncManager.java
+++ b/src/com/android/exchange/SyncManager.java
@@ -1651,8 +1651,9 @@
for (long mailboxId: mServiceMap.keySet()) {
Mailbox m = Mailbox.restoreMailboxWithId(this, mailboxId);
if (m != null) {
- if (m.mAccountKey == accountId &&
- m.mServerId.startsWith(Eas.ACCOUNT_MAILBOX_PREFIX)) {
+ String serverId = m.mServerId;
+ if (m.mAccountKey == accountId && serverId != null &&
+ serverId.startsWith(Eas.ACCOUNT_MAILBOX_PREFIX)) {
// Here's our account mailbox; reset him (stopping pings)
AbstractSyncService svc = mServiceMap.get(mailboxId);
svc.reset();