diff --git a/provider_src/com/android/email/mail/store/ImapFolder.java b/provider_src/com/android/email/mail/store/ImapFolder.java index 05f44c477..bb7a6fe4b 100644 --- a/provider_src/com/android/email/mail/store/ImapFolder.java +++ b/provider_src/com/android/email/mail/store/ImapFolder.java @@ -84,6 +84,10 @@ public class ImapFolder extends Folder { * Invoked when the connection enters idle mode */ public void onIdled(); + /** + * Invoked when idle state is left + */ + public void onIdlingDone(); /** * Invoked when a new change is communicated by the server. * @@ -313,6 +317,9 @@ public class ImapFolder extends Folder { mIdling = false; } + if (callback != null) { + callback.onIdlingDone(); + } } catch (MessagingException me) { cleanupConnection(connection, false); synchronized (mIdleSync) { diff --git a/provider_src/com/android/email/service/ImapService.java b/provider_src/com/android/email/service/ImapService.java index 292a64218..52ba306d3 100644 --- a/provider_src/com/android/email/service/ImapService.java +++ b/provider_src/com/android/email/service/ImapService.java @@ -197,6 +197,12 @@ public class ImapService extends Service { scheduleKickIdleConnection(); } + @Override + public void onIdlingDone() { + cancelKickIdleConnection(); + resetPingDelay(); + } + @Override public void onNewServerChange(final boolean needSync, final List fetchMessages) { // Instead of checking every received change, request a sync of the mailbox @@ -551,6 +557,10 @@ public class ImapService extends Service { mContext = context; } + public void destroy() { + cancelIdleConnectionRestart(); + } + @Override public void onConnectivityRestored(int networkType) { if (Logging.LOGD) { @@ -778,6 +788,7 @@ public class ImapService extends Service { ImapIdleFolderHolder.getInstance().unregisterAllIdledMailboxes(true); mConnectivityManager.unregister(); getContentResolver().unregisterContentObserver(mLocalChangesObserver); + mConnectivityManager.destroy(); super.onDestroy(); }