From c48670a5692144b293cea1c42b138e5228860da4 Mon Sep 17 00:00:00 2001 From: Yu Ping Hu Date: Fri, 13 Sep 2013 17:49:12 -0700 Subject: [PATCH] Only set sync mailbox to inbox if none was specified. Follow up to I9e62d5de10222f1d81b47a68dd0b3ab05de5436d. Bug: 10729228 Change-Id: I8100a0a5d965e4c4c86dccb6c94dfe26cc6e49a0 --- .../email/service/PopImapSyncAdapterService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/service/PopImapSyncAdapterService.java b/src/com/android/email/service/PopImapSyncAdapterService.java index bfe4efe27..2f817bff0 100644 --- a/src/com/android/email/service/PopImapSyncAdapterService.java +++ b/src/com/android/email/service/PopImapSyncAdapterService.java @@ -204,16 +204,21 @@ public class PopImapSyncAdapterService extends Service { } else { LogUtils.d(TAG, "Sync request for " + acct.mDisplayName); LogUtils.d(TAG, extras.toString()); - long mailboxId = - extras.getLong(Mailbox.SYNC_EXTRA_MAILBOX_ID, Mailbox.NO_MAILBOX); // We update our folder structure on every sync. final EmailServiceProxy service = EmailServiceUtils.getServiceForAccount(context, acct.mId); service.updateFolderList(acct.mId); - mailboxId = Mailbox.findMailboxOfType(context, acct.mId, - Mailbox.TYPE_INBOX); + // Get the id for the mailbox we want to sync. + long mailboxId = + extras.getLong(Mailbox.SYNC_EXTRA_MAILBOX_ID, Mailbox.NO_MAILBOX); + if (mailboxId == Mailbox.NO_MAILBOX) { + // If the extras didn't specify a mailbox, assume we want the inbox. + // TODO: IMAP may eventually want to allow multiple auto-sync mailboxes. + mailboxId = Mailbox.findMailboxOfType(context, acct.mId, + Mailbox.TYPE_INBOX); + } if (mailboxId == Mailbox.NO_MAILBOX) return; boolean uiRefresh = extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false);