am 7266d90d: Make mailboxes respect the sync interval of the Account

Merge commit '7266d90daccee82cb398356defb0c30d95a2ebdd'

* commit '7266d90daccee82cb398356defb0c30d95a2ebdd':
  Make mailboxes respect the sync interval of the Account
This commit is contained in:
Marc Blank 2009-08-31 21:50:22 -07:00 committed by Android Git Automerger
commit bbb103a349
2 changed files with 15 additions and 19 deletions

View File

@ -389,20 +389,17 @@ public class SyncManager extends Service implements Runnable {
} else {
// See whether any of our accounts has changed sync interval or window
if (syncParametersChanged(account)) {
// Here's one that has...
INSTANCE.log("Account " + account.mDisplayName +
" changed; stopping running syncs...");
// If account is push, set contacts and inbox to push
// Set pushable boxes' sync interval to the sync interval of the Account
Account updatedAccount =
Account.restoreAccountWithId(getContext(), account.mId);
if (updatedAccount.mSyncInterval == Account.CHECK_INTERVAL_PUSH) {
ContentValues cv = new ContentValues();
cv.put(MailboxColumns.SYNC_INTERVAL, Mailbox.CHECK_INTERVAL_PUSH);
getContext().getContentResolver().update(Mailbox.CONTENT_URI, cv,
WHERE_IN_ACCOUNT_AND_PUSHABLE,
new String[] {Long.toString(account.mId)});
}
ContentValues cv = new ContentValues();
cv.put(MailboxColumns.SYNC_INTERVAL, updatedAccount.mSyncInterval);
getContentResolver().update(Mailbox.CONTENT_URI, cv,
WHERE_IN_ACCOUNT_AND_PUSHABLE,
new String[] {Long.toString(account.mId)});
// Stop all current syncs; the appropriate ones will restart
INSTANCE.log("Account " + account.mDisplayName +
" changed; stop running syncs...");
stopAccountSyncs(account.mId, true);
}
}

View File

@ -208,14 +208,19 @@ public class FolderSyncParser extends AbstractSyncParser {
m.mServerId = serverId;
m.mAccountKey = mAccountId;
m.mType = Mailbox.TYPE_MAIL;
// Note that all mailboxes default to checking "never" (i.e. manual sync only)
// We set specific intervals for inbox, contacts, and (eventually) calendar
m.mSyncInterval = Mailbox.CHECK_INTERVAL_NEVER;
switch (type) {
case INBOX_TYPE:
m.mSyncInterval = Mailbox.CHECK_INTERVAL_PUSH;
m.mType = Mailbox.TYPE_INBOX;
m.mSyncInterval = mAccount.mSyncInterval;
break;
case CONTACTS_TYPE:
m.mType = Mailbox.TYPE_CONTACTS;
m.mSyncInterval = mAccount.mSyncInterval;
break;
case OUTBOX_TYPE:
m.mSyncInterval = Mailbox.CHECK_INTERVAL_NEVER;
// TYPE_OUTBOX mailboxes are known by SyncManager to sync whenever they aren't
// empty. The value of mSyncFrequency is ignored for this kind of mailbox.
m.mType = Mailbox.TYPE_OUTBOX;
@ -231,14 +236,8 @@ public class FolderSyncParser extends AbstractSyncParser {
break;
case CALENDAR_TYPE:
m.mType = Mailbox.TYPE_CALENDAR;
// TODO This could be push, depending on settings
// For now, no sync, since it's not yet implemented
break;
case CONTACTS_TYPE:
m.mType = Mailbox.TYPE_CONTACTS;
// TODO Frequency below should depend on settings
m.mSyncInterval = Mailbox.CHECK_INTERVAL_PUSH;
break;
}
// Make boxes like Contacts and Calendar invisible in the folder list