Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

If we're stopped, make sure watchdog alarm is also stopped

Bug: 5647625
Change-Id: I33e94107f2d6e4a38a5a221df72ed83596ca7c54
  • Loading branch information...
commit ecaa97741332e506afade647402896993ba64fba 1 parent 0767601
Marc Blank authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 src/com/android/email/service/AttachmentDownloadService.java
View
17 src/com/android/email/service/AttachmentDownloadService.java
@@ -405,13 +405,22 @@ public synchronized boolean isEmpty() {
return count;
}
+ private void cancelWatchdogAlarm() {
+ if (mAlarmManager != null && mWatchdogPendingIntent != null) {
+ mAlarmManager.cancel(mWatchdogPendingIntent);
+ }
+ }
+
/**
* Watchdog for downloads; we use this in case we are hanging on a download, which might
* have failed silently (the connection dropped, for example)
*/
private void onWatchdogAlarm() {
- // If our service instance is gone, just leave...
- if (mStop) return;
+ // If our service instance is gone, just leave (but cancel alarm first!)
+ if (mStop) {
+ cancelWatchdogAlarm();
+ return;
+ }
long now = System.currentTimeMillis();
for (DownloadRequest req: mDownloadsInProgress.values()) {
// Check how long it's been since receiving a callback
@@ -425,9 +434,7 @@ private void onWatchdogAlarm() {
}
// If there are downloads in progress, reset alarm
if (mDownloadsInProgress.isEmpty()) {
- if (mAlarmManager != null && mWatchdogPendingIntent != null) {
- mAlarmManager.cancel(mWatchdogPendingIntent);
- }
+ cancelWatchdogAlarm();
}
// Check whether we can start new downloads...
if (mConnectivityManager != null && mConnectivityManager.hasConnectivity()) {
Please sign in to comment.
Something went wrong with that request. Please try again.