summaryrefslogtreecommitdiffstats
path: root/provider_src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2015-06-09 12:54:00 +0200
committerSteve Kondik <steve@cyngn.com>2015-10-18 14:05:32 -0700
commit006ea81b71a4bc60f5fad8df454a2c25c12cd415 (patch)
tree375157ccc62935de3c46fdb756448caf5d4193d2 /provider_src
parentd13071399fe3d396903564ffbe5115a2b03a1d30 (diff)
downloadandroid_packages_apps_Email-006ea81b71a4bc60f5fad8df454a2c25c12cd415.tar.gz
android_packages_apps_Email-006ea81b71a4bc60f5fad8df454a2c25c12cd415.tar.bz2
android_packages_apps_Email-006ea81b71a4bc60f5fad8df454a2c25c12cd415.zip
Don't solely rely on the presence of RECENT for checking for new mail.
It may happen (depending on server and/or timing) that only an EXISTS response is sent to the IDLE connection when new mail arrives. Don't discard that response, but evaluate it to determine whether there's new mail by checking whether the message count increased. Change-Id: Ia49714e6cd42dd71dfda8b7bbdf1fd622972edda
Diffstat (limited to 'provider_src')
-rw-r--r--provider_src/com/android/email/mail/store/ImapFolder.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/provider_src/com/android/email/mail/store/ImapFolder.java b/provider_src/com/android/email/mail/store/ImapFolder.java
index 51e99d97a..97dca901d 100644
--- a/provider_src/com/android/email/mail/store/ImapFolder.java
+++ b/provider_src/com/android/email/mail/store/ImapFolder.java
@@ -548,7 +548,9 @@ public class ImapFolder extends Folder {
@Override
public int getMessageCount() {
- return mMessageCount;
+ synchronized (this) {
+ return mMessageCount;
+ }
}
@Override
@@ -1103,7 +1105,9 @@ public class ImapFolder extends Folder {
*/
private void handleUntaggedResponse(ImapResponse response) {
if (response.isDataResponse(1, ImapConstants.EXISTS)) {
- mMessageCount = response.getStringOrEmpty(0).getNumberOrZero();
+ synchronized (this) {
+ mMessageCount = response.getStringOrEmpty(0).getNumberOrZero();
+ }
}
}
@@ -1541,9 +1545,10 @@ public class ImapFolder extends Folder {
// OK DONE
// No more changes
// n EXISTS
- // Indicates that the mailbox changed => ignore
+ // Indicates the number of messages in the mailbox => handle like
+ // RECENT if the number increased
// n EXPUNGE
- // Indicates a message were completely deleted => a full sync is required
+ // Indicates a message was completely deleted => a full sync is required
// n RECENT
// New messages waiting in the server => use UIDNEXT to search for the new messages.
// If isn't possible to retrieve the new UID messages, then a full sync is required
@@ -1587,9 +1592,24 @@ public class ImapFolder extends Folder {
if (op.is(ImapConstants.DONE)) {
break;
} else if (op.is(ImapConstants.EXISTS)) {
- continue;
+ int newMessageCount = change.getStringOrEmpty(0).getNumberOrZero();
+ int oldMessageCount;
+ synchronized (this) {
+ oldMessageCount = mMessageCount;
+ mMessageCount = newMessageCount;
+ }
+ if (Logging.LOGD) {
+ LogUtils.d(LOG_TAG, "Got EXISTS idle response, message count now "
+ + newMessageCount + ", was " + oldMessageCount);
+ }
+ if (newMessageCount > oldMessageCount) {
+ hasNewMessages = true;
+ }
} else if (op.is(ImapConstants.EXPUNGE)) {
imapIdleChanges.mRequiredSync = true;
+ synchronized (this) {
+ mMessageCount--;
+ }
} else if (op.is(ImapConstants.RECENT)) {
hasNewMessages = true;
} else if (op.is(ImapConstants.FETCH)