Add logging to see why attachments fail to load

b/11436795
Now, if we ever insert or update an attachment to have
a blank location, we'll log a warning with stack trace.
Also, logging from ADS now uses the same log tag as everything
else, so we'll be able to see it without needing to turn
on some funny log tag.

Change-Id: Ic566cd87e8893128d074b897d7594a01ae12bc8c
diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java
index ebdbba5..033e368 100644
--- a/src/com/android/email/provider/EmailProvider.java
+++ b/src/com/android/email/provider/EmailProvider.java
@@ -863,6 +863,9 @@
                                 flags = values.getAsInteger(Attachment.FLAGS);
                             }
                             // Report all new attachments to the download service
+                            if (TextUtils.isEmpty(values.getAsString(Attachment.LOCATION))) {
+                                LogUtils.w(TAG, new Throwable(), "attachment with blank location");
+                            }
                             mAttachmentService.attachmentChanged(getContext(), longId, flags);
                             break;
                     }
@@ -1875,6 +1878,12 @@
                 case ACCOUNT:
                 case HOSTAUTH:
                 case POLICY:
+                    if (match == ATTACHMENT) {
+                        if (values.containsKey(AttachmentColumns.LOCATION) &&
+                                TextUtils.isEmpty(values.getAsString(AttachmentColumns.LOCATION))) {
+                            LogUtils.w(TAG, new Throwable(), "attachment with blank location");
+                        }
+                    }
                     result = db.update(tableName, values, selection, selectionArgs);
                     break;
 
@@ -4700,6 +4709,12 @@
                         destinationValue == null ? 0 : destinationValue);
                 values.put(AttachmentColumns.FLAGS,
                         attachment.mFlags | Attachment.FLAG_DOWNLOAD_USER_REQUEST);
+
+                if (values.containsKey(AttachmentColumns.LOCATION) &&
+                        TextUtils.isEmpty(values.getAsString(AttachmentColumns.LOCATION))) {
+                    LogUtils.w(TAG, new Throwable(), "attachment with blank location");
+                }
+
                 attachment.update(context, values);
                 result = 1;
             }
diff --git a/src/com/android/email/service/AttachmentDownloadService.java b/src/com/android/email/service/AttachmentDownloadService.java
index 357e9e3..2aeccea 100644
--- a/src/com/android/email/service/AttachmentDownloadService.java
+++ b/src/com/android/email/service/AttachmentDownloadService.java
@@ -59,7 +59,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 public class AttachmentDownloadService extends Service implements Runnable {
-    public static final String TAG = "AttachmentService";
+    public static final String TAG = LogUtils.TAG;
 
     // Minimum wait time before retrying a download that failed due to connection error
     private static final long CONNECTION_ERROR_RETRY_MILLIS = 10 * DateUtils.SECOND_IN_MILLIS;
@@ -714,7 +714,7 @@
                     }
                     if (statusCode != EmailServiceStatus.IN_PROGRESS) {
                         LogUtils.d(TAG, ">> Attachment " + attachmentId + ": " + code);
-                    } else if (progress >= (req.lastProgress + 15)) {
+                    } else if (progress >= (req.lastProgress + 10)) {
                         LogUtils.d(TAG, ">> Attachment " + attachmentId + ": " + progress + "%");
                     }
                 }