summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2015-06-17 12:58:26 +0200
committerDanny Baumann <dannybaumann@web.de>2015-06-18 12:45:19 +0200
commit2f399edfbd6dae2ea53195467c151bd01e9c1260 (patch)
tree8a530fcdab6c138b0a61252b7780125f4e6fe86a
parentb12754d61f2dc3eb9cf6e6b5dcfd564296c13993 (diff)
downloadandroid_packages_apps_Email-2f399edfbd6dae2ea53195467c151bd01e9c1260.tar.gz
android_packages_apps_Email-2f399edfbd6dae2ea53195467c151bd01e9c1260.tar.bz2
android_packages_apps_Email-2f399edfbd6dae2ea53195467c151bd01e9c1260.zip
Don't cancel PendingIntents used for AlarmManager.
Creating new ones (which is the implicit effect of FLAG_CANCEL_CURRENT) causes PendingIntent.equals() to return false for the new and the old instance, which in turn leads to AlarmManager failing to remove the alarm. Also remove the unneeded request code offsets. The intent actions for the various actions are already distinct, so we need to only identify between the intents that have the same actions; using the mailbox ID as request code is sufficient for that purpose. Change-Id: I9030c24a9c6b1c722b246601fde741f7027d3de7
-rw-r--r--provider_src/com/android/email/service/ImapService.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/provider_src/com/android/email/service/ImapService.java b/provider_src/com/android/email/service/ImapService.java
index 7f7d568d5..12ca77245 100644
--- a/provider_src/com/android/email/service/ImapService.java
+++ b/provider_src/com/android/email/service/ImapService.java
@@ -111,8 +111,6 @@ public class ImapService extends Service {
// Kick idle connection every ~25 minutes (in a window between 25 and 28 minutes)
private static final int KICK_IDLE_CONNECTION_TIMEOUT = 25 * 60 * 1000;
private static final int KICK_IDLE_CONNECTION_MAX_DELAY = 3 * 60 * 1000;
- private static final int ALARM_REQUEST_KICK_IDLE_CODE = 1000;
- private static final int ALARM_REQUEST_REFRESH_IDLE_CODE = 1001;
// Restart idle connection between 30 seconds and 1 minute after re-gaining connectivity
private static final int RESTART_IDLE_DELAY_MIN = 30 * 1000;
@@ -291,12 +289,11 @@ public class ImapService extends Service {
}
private PendingIntent getIdleRefreshIntent() {
- int requestCode = ALARM_REQUEST_REFRESH_IDLE_CODE + (int) mMailbox.mId;
Intent i = new Intent(mContext, ImapService.class);
i.setAction(ACTION_RESTART_IDLE_CONNECTION);
- i.putExtra(EXTRA_MAILBOX, (int) mMailbox.mId);
- return PendingIntent.getService(mContext, requestCode, i,
- PendingIntent.FLAG_CANCEL_CURRENT);
+ i.putExtra(EXTRA_MAILBOX, mMailbox.mId);
+ return PendingIntent.getService(mContext, (int) mMailbox.mId, i,
+ PendingIntent.FLAG_UPDATE_CURRENT);
}
private void scheduleKickIdleConnection() {
@@ -313,12 +310,11 @@ public class ImapService extends Service {
}
private PendingIntent getKickIdleConnectionPendingIntent() {
- int requestCode = ALARM_REQUEST_KICK_IDLE_CODE + (int) mMailbox.mId;
Intent i = new Intent(mContext, ImapService.class);
i.setAction(ACTION_KICK_IDLE_CONNECTION);
i.putExtra(EXTRA_MAILBOX, mMailbox.mId);
- return PendingIntent.getService(mContext, requestCode,
- i, PendingIntent.FLAG_CANCEL_CURRENT);
+ return PendingIntent.getService(mContext, (int) mMailbox.mId,
+ i, PendingIntent.FLAG_UPDATE_CURRENT);
}
}
@@ -591,7 +587,7 @@ public class ImapService extends Service {
private PendingIntent getIdleConnectionRestartIntent() {
Intent i = new Intent(mContext, ImapService.class);
i.setAction(ACTION_RESTART_ALL_IDLE_CONNECTIONS);
- return PendingIntent.getService(mContext, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
+ return PendingIntent.getService(mContext, 0, i, 0);
}
}