Ignore notifications for unloaded messages

Seems like POP envelopes could get into the database and tickle the
NotificationController even before we got the full subject/sender. Just
ignore those things until the basic info is loaded.

Bug: 5061271
Change-Id: Iadfbff8a1615d2644880f5cae3727768f4f9549a
diff --git a/src/com/android/email/NotificationController.java b/src/com/android/email/NotificationController.java
index 80bc6b1..ea56fb9 100644
--- a/src/com/android/email/NotificationController.java
+++ b/src/com/android/email/NotificationController.java
@@ -110,7 +110,7 @@
      * several notifications consecutively, it can be pretty overwhelming to get a barrage of
      * notification sounds. Throttle them using this value.
      */
-    private static final long MIN_SOUND_INTERVAL = 15 * 1000; // 15 seconds
+    private static final long MIN_SOUND_INTERVAL_MS = 15 * 1000; // 15 seconds
 
     /** Constructor */
     @VisibleForTesting
@@ -428,7 +428,7 @@
         }
 
         long now = mClock.getTime();
-        boolean enableAudio = (now - mLastMessageNotifyTime) > MIN_SOUND_INTERVAL;
+        boolean enableAudio = (now - mLastMessageNotifyTime) > MIN_SOUND_INTERVAL_MS;
         Notification notification = createAccountNotification(
                 account, title.toString(), title, text,
                 intent, largeIcon, number, enableAudio);
@@ -600,8 +600,10 @@
     private static class MessageContentObserver extends ContentObserver {
         /** A selection to get messages the user hasn't seen before */
         private final static String MESSAGE_SELECTION =
-            MessageColumns.MAILBOX_KEY + "=? AND " + MessageColumns.ID + ">? AND "
-            + MessageColumns.FLAG_READ + "=0";
+                MessageColumns.MAILBOX_KEY + "=? AND "
+                + MessageColumns.ID + ">? AND "
+                + MessageColumns.FLAG_READ + "=0 AND "
+                + Message.FLAG_LOADED_SELECTION;
         private final Context mContext;
         private final long mMailboxId;
         private final long mAccountId;