From 69418d04606419fca80a0c368d650c4bedffb656 Mon Sep 17 00:00:00 2001 From: Yu Ping Hu Date: Thu, 26 Sep 2013 22:17:48 -0700 Subject: [PATCH] Kick the push once an hour, in case it fails. Bug: 10954795 Change-Id: If6325c04b2011fb476f20f1419afaee13a786d3c --- src/com/android/email/provider/EmailProvider.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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); } }