diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 93d4f476b..ebc064980 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -4847,6 +4847,12 @@ public class EmailProvider extends ContentProvider { return new android.accounts.Account(emailAddress, info.accountType); } + /** + * The amount of time between periodic syncs intended to ensure that push hasn't died. + */ + private static final long KICK_SYNC_INTERVAL = + DateUtils.HOUR_IN_MILLIS / DateUtils.SECOND_IN_MILLIS; + /** * Update an account's periodic sync if the sync interval has changed. * @param accountId id for the account to update. @@ -4879,6 +4885,13 @@ public class EmailProvider extends ContentProvider { if (syncInterval > 0) { ContentResolver.addPeriodicSync(account, EmailContent.AUTHORITY, Bundle.EMPTY, syncInterval * DateUtils.MINUTE_IN_MILLIS / DateUtils.SECOND_IN_MILLIS); + } else if (syncInterval == Account.CHECK_INTERVAL_PUSH) { + // Schedule a periodic sync to restart the push in case it fails. + // TODO: Make this unnecessary by having push not break. + final Bundle extras = new Bundle(1); + extras.putLong(Mailbox.SYNC_EXTRA_MAILBOX_ID, Mailbox.SYNC_EXTRA_MAILBOX_ID_PUSH_ONLY); + ContentResolver.addPeriodicSync(account, EmailContent.AUTHORITY, extras, + KICK_SYNC_INTERVAL); } }