diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java index 9bad28766..dfa3738cf 100644 --- a/src/com/android/exchange/EasSyncService.java +++ b/src/com/android/exchange/EasSyncService.java @@ -1020,9 +1020,9 @@ public class EasSyncService extends AbstractSyncService { mAccount = Account.restoreAccountWithId(mContext, mAccount.mId); mProtocolVersion = mAccount.mProtocolVersion; mProtocolVersionDouble = Double.parseDouble(mProtocolVersion); - if (mMailbox.mType == Mailbox.TYPE_CONTACTS) + if (mMailbox.mType == Mailbox.TYPE_CONTACTS) { target = new ContactsSyncAdapter(mMailbox, this); - else { + } else { target = new EmailSyncAdapter(mMailbox, this); } // We loop here because someone might have put a request in while we were syncing diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index 30755f280..986946ae4 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -347,6 +347,15 @@ public class SyncManager extends Service implements Runnable { } return false; } + + public Account getById(long id) { + for (Account account: this) { + if (account.mId == id) { + return account; + } + } + return null; + } } class AccountObserver extends ContentObserver { @@ -564,6 +573,10 @@ public class SyncManager extends Service implements Runnable { } } + private Account getAccountById(long accountId) { + return mAccountObserver.mAccounts.getById(accountId); + } + public class SyncStatus { static public final int NOT_RUNNING = 0; static public final int DIED = 1; @@ -1339,10 +1352,25 @@ public class SyncManager extends Service implements Runnable { } } long freq = c.getInt(Mailbox.CONTENT_SYNC_INTERVAL_COLUMN); + int type = c.getInt(Mailbox.CONTENT_TYPE_COLUMN); + if (type == Mailbox.TYPE_CONTACTS) { + // See if "sync automatically" is set + Account account = + getAccountById(c.getInt(Mailbox.CONTENT_ACCOUNT_KEY_COLUMN)); + if (account != null) { + android.accounts.Account a = + new android.accounts.Account(account.mEmailAddress, + Eas.ACCOUNT_MANAGER_TYPE); + if (!ContentResolver.getSyncAutomatically(a, + ContactsContract.AUTHORITY)) { + continue; + } + } + } if (freq == Mailbox.CHECK_INTERVAL_PUSH) { Mailbox m = EmailContent.getContent(c, Mailbox.class); startService(m, SYNC_PUSH, null); - } else if (c.getInt(Mailbox.CONTENT_TYPE_COLUMN) == Mailbox.TYPE_OUTBOX) { + } else if (type == Mailbox.TYPE_OUTBOX) { int cnt = EmailContent.count(this, Message.CONTENT_URI, EasOutboxService.MAILBOX_KEY_AND_NOT_SEND_FAILED, new String[] {Long.toString(mid)});