Don't bail out of downloading an attachment if the size is delcared as zero

b/11225306

Change-Id: If67401dd3e6b652b03fba2e71cfc82fdae80ccb2
diff --git a/src/com/android/email/mail/store/ImapFolder.java b/src/com/android/email/mail/store/ImapFolder.java
index 02c1ee7..0dd79b5 100644
--- a/src/com/android/email/mail/store/ImapFolder.java
+++ b/src/com/android/email/mail/store/ImapFolder.java
@@ -740,7 +740,7 @@
                         InputStream bodyStream = body.getAsStream();
                         message.parse(bodyStream);
                     }
-                    if (fetchPart != null && fetchPart.getSize() > 0) {
+                    if (fetchPart != null) {
                         InputStream bodyStream =
                                 fetchList.getKeyedStringOrEmpty("BODY[", true).getAsStream();
                         String encodings[] = fetchPart.getHeader(
@@ -801,7 +801,12 @@
                 out.write(buffer, 0, n);
                 count += n;
                 if (listener != null) {
-                    listener.loadAttachmentProgress(count * 100 / size);
+                    if (size == 0) {
+                        // We don't know how big the file is, so just fake it.
+                        listener.loadAttachmentProgress((int)Math.ceil(100 * (1-1.0/count)));
+                    } else {
+                        listener.loadAttachmentProgress(count * 100 / size);
+                    }
                 }
             }
         } catch (Base64DataException bde) {