From cb2f0a8bb9ff6728a111b1f790c12555ac7086fb Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 26 Jul 2011 09:57:24 -0700 Subject: [PATCH] Ignore watchdog alarms for stopped service Bug: 5055519 Change-Id: I35352364f3f2842932ad40e47d70646bb6d42349 --- .../android/email/service/AttachmentDownloadService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/service/AttachmentDownloadService.java b/src/com/android/email/service/AttachmentDownloadService.java index 9fe072fd1..9a6361e73 100644 --- a/src/com/android/email/service/AttachmentDownloadService.java +++ b/src/com/android/email/service/AttachmentDownloadService.java @@ -402,7 +402,13 @@ public class AttachmentDownloadService extends Service implements Runnable { return count; } + /** + * 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; long now = System.currentTimeMillis(); for (DownloadRequest req: mDownloadsInProgress.values()) { // Check how long it's been since receiving a callback @@ -932,8 +938,9 @@ public class AttachmentDownloadService extends Service implements Runnable { public void onDestroy() { // STOPSHIP Remove this, and other, lifecycle logging Log.d(TAG, "**** ON DESTROY!"); + // Mark this instance of the service as stopped + mStop = true; if (sRunningService != null) { - mStop = true; kick(); sRunningService = null; }