summaryrefslogtreecommitdiff
path: root/exchange2/src/com/android/exchange/ExchangeService.java
diff options
context:
space:
mode:
Diffstat (limited to 'exchange2/src/com/android/exchange/ExchangeService.java')
-rw-r--r--exchange2/src/com/android/exchange/ExchangeService.java30
1 files changed, 20 insertions, 10 deletions
diff --git a/exchange2/src/com/android/exchange/ExchangeService.java b/exchange2/src/com/android/exchange/ExchangeService.java
index be2ad65e..0310008a 100644
--- a/exchange2/src/com/android/exchange/ExchangeService.java
+++ b/exchange2/src/com/android/exchange/ExchangeService.java
@@ -642,7 +642,7 @@ public class ExchangeService extends Service implements Runnable {
}
}
- private boolean onSecurityHold(Account account) {
+ static boolean onSecurityHold(Account account) {
return (account.mFlags & Account.FLAGS_SECURITY_HOLD) != 0;
}
@@ -690,7 +690,7 @@ public class ExchangeService extends Service implements Runnable {
PolicyServiceProxy.setAccountHoldFlag(ExchangeService.this,
account, false);
log("isActive true; release hold for " + account.mDisplayName);
- }
+ }
}
}
}
@@ -2162,7 +2162,11 @@ public class ExchangeService extends Service implements Runnable {
if (policy == null) {
policy = Policy.restorePolicyWithId(INSTANCE, policyKey);
account.mPolicy = policy;
- if (!PolicyServiceProxy.isActive(exchangeService, policy)) return false;
+ if (!PolicyServiceProxy.isActive(exchangeService, policy)) {
+ PolicyServiceProxy.setAccountHoldFlag(exchangeService, account, true);
+ log("canAutoSync; policies not active, set hold flag");
+ return false;
+ }
}
if (policy != null && policy.mRequireManualSyncWhenRoaming && networkInfo.isRoaming()) {
return false;
@@ -2280,7 +2284,7 @@ public class ExchangeService extends Service implements Runnable {
if (c == null) throw new ProviderUnavailableException();
try {
while (c.moveToNext()) {
- long mailboxId = c.getLong(Mailbox.CONTENT_ID_COLUMN);
+ final long mailboxId = c.getLong(Mailbox.CONTENT_ID_COLUMN);
AbstractSyncService service = null;
synchronized (sSyncLock) {
service = mServiceMap.get(mailboxId);
@@ -2290,12 +2294,6 @@ public class ExchangeService extends Service implements Runnable {
Account account = getAccountById(c.getInt(Mailbox.CONTENT_ACCOUNT_KEY_COLUMN));
if (account == null) continue;
- // We handle a few types of mailboxes specially
- int mailboxType = c.getInt(Mailbox.CONTENT_TYPE_COLUMN);
- if (!isMailboxSyncable(account, mailboxType)) {
- continue;
- }
-
// Check whether we're in a hold (temporary or permanent)
SyncError syncError = mSyncErrorMap.get(mailboxId);
if (syncError != null) {
@@ -2315,6 +2313,18 @@ public class ExchangeService extends Service implements Runnable {
}
}
+ // We handle a few types of mailboxes specially
+ final int mailboxType = c.getInt(Mailbox.CONTENT_TYPE_COLUMN);
+ if (!isMailboxSyncable(account, mailboxType)) {
+ // If there isn't an entry in the sync error map, in case of a security
+ // hold, add one to allow the next sync to be deferred
+ if (syncError == null && onSecurityHold(account)) {
+ mSyncErrorMap.put(mailboxId,
+ new SyncError(AbstractSyncService.EXIT_SECURITY_FAILURE, true));
+ }
+ continue;
+ }
+
// Otherwise, we use the sync interval
long syncInterval = c.getInt(Mailbox.CONTENT_SYNC_INTERVAL_COLUMN);
if (syncInterval == Mailbox.CHECK_INTERVAL_PUSH) {