From de4c230f008ca0615b8035a560cd512624ac2cdb Mon Sep 17 00:00:00 2001 From: Yu Ping Hu Date: Mon, 1 Apr 2013 19:57:13 -0700 Subject: [PATCH] Exclude not fully loaded messages from uimessages queries. Bug: 8370633 Change-Id: I5643454333b490bb1a988efb7b59e20b18fa67f4 --- src/com/android/email/provider/EmailProvider.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 057dcb221..e8cc1ec46 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -2529,7 +2529,9 @@ outer: */ private static String genQueryMailboxMessages(String[] uiProjection, final boolean unseenOnly) { StringBuilder sb = genSelect(getMessageListMap(), uiProjection); - sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + Message.MAILBOX_KEY + "=? "); + sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + + Message.FLAG_LOADED + "=" + Message.FLAG_LOADED_COMPLETE + " AND " + + Message.MAILBOX_KEY + "=? "); if (unseenOnly) { sb.append("AND ").append(MessageColumns.FLAG_SEEN).append(" = 0 "); } @@ -2550,11 +2552,12 @@ outer: ContentValues values = new ContentValues(); values.put(UIProvider.ConversationColumns.COLOR, CONVERSATION_COLOR); StringBuilder sb = genSelect(getMessageListMap(), uiProjection, values); + sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + + Message.FLAG_LOADED + "=" + Message.FLAG_LOADED_COMPLETE + " AND "); if (isCombinedMailbox(mailboxId)) { switch (getVirtualMailboxType(mailboxId)) { case Mailbox.TYPE_INBOX: - sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + - MessageColumns.MAILBOX_KEY + " IN (SELECT " + MailboxColumns.ID + + sb.append(MessageColumns.MAILBOX_KEY + " IN (SELECT " + MailboxColumns.ID + " FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.TYPE + "=" + Mailbox.TYPE_INBOX + ") "); if (unseenOnly) { @@ -2563,8 +2566,7 @@ outer: sb.append("ORDER BY " + MessageColumns.TIMESTAMP + " DESC"); break; case Mailbox.TYPE_STARRED: - sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + - MessageColumns.FLAG_FAVORITE + "=1 "); + sb.append(MessageColumns.FLAG_FAVORITE + "=1 "); if (unseenOnly) { sb.append("AND ").append(MessageColumns.FLAG_SEEN).append(" = 0 "); } @@ -2577,8 +2579,7 @@ outer: } else { switch (getVirtualMailboxType(mailboxId)) { case Mailbox.TYPE_STARRED: - sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + - MessageColumns.ACCOUNT_KEY + "=? AND " + + sb.append(MessageColumns.ACCOUNT_KEY + "=? AND " + MessageColumns.FLAG_FAVORITE + "=1 ORDER BY " + MessageColumns.TIMESTAMP + " DESC"); break;