From 36cc9c18edb7ee897d0d758788b6e338cb2ef126 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Fri, 14 Jan 2011 11:47:26 -0800 Subject: [PATCH] Fix NPE in AttachmentDownloadServiceTests.testDownloadSet Bug 3353834 Change-Id: I5cf475ff174bffce80a435c80b1fd85c0be146e9 --- .../android/email/service/AttachmentDownloadService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/android/email/service/AttachmentDownloadService.java b/src/com/android/email/service/AttachmentDownloadService.java index 85fb4c34c..191402e28 100644 --- a/src/com/android/email/service/AttachmentDownloadService.java +++ b/src/com/android/email/service/AttachmentDownloadService.java @@ -90,7 +90,7 @@ public class AttachmentDownloadService extends Service implements Runnable { /*package*/ static AttachmentDownloadService sRunningService = null; /*package*/ Context mContext; - Preferences mPreferences; + private final Preferences mPreferences; /*package*/ final DownloadSet mDownloadSet = new DownloadSet(new DownloadComparator()); private final HashMap> mAccountServiceMap = @@ -521,7 +521,7 @@ public class AttachmentDownloadService extends Service implements Runnable { } // If we're an attachment on forwarded mail, and if we're not still blocked, // try to send pending mail now (as mediated by MailService) - if ((req != null) && + if ((req != null) && !Utility.hasUnloadedAttachments(mContext, attachment.mMessageKey)) { if (Email.DEBUG) { Log.d(TAG, "== Downloads finished for outgoing msg #" + req.messageId); @@ -547,6 +547,10 @@ public class AttachmentDownloadService extends Service implements Runnable { } } + public AttachmentDownloadService() { + mPreferences = Preferences.getPreferences(this); + } + /** * Calculate the download priority of an Attachment. A priority of zero means that the * attachment is not marked for download. @@ -786,7 +790,6 @@ public class AttachmentDownloadService extends Service implements Runnable { public void run() { mContext = this; mAccountManagerStub = new AccountManagerStub(this); - mPreferences = Preferences.getPreferences(this); // Run through all attachments in the database that require download and add them to // the queue