aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-01-10 14:15:38 -0800
committerJay Shrauner <shrauner@google.com>2014-03-01 18:38:13 +0000
commit60189cdce174667bf9c2a90fbf9e7a3b04d856e5 (patch)
tree713b80c0e0ae73cbb8f4a493dd95bb311d8c1f21
parent7b8bf370a85ff023ce22b3e5e9bd065293c5b61c (diff)
downloadContactsProvider-kitkat-wear.tar.gz
When there are there are two identical email data items, each belonging to a different sync adapter account, the "SELECT DISTINCT" operator causes the two emails to be incorrectly grouped before the account prioritization sort order is applied. This can cause the email address to be labelled with the wrong account, causing it to be incorrectly ranked as an email address from another account. To fix this, account name and type is added to the group by clause to ensure that each email address is grouped correctly based on their account before ranking them by account priority. Bug: 12207447 Change-Id: Ib79f6c36ee6a83838bcaa82487f2f7fb9716bbf4 (cherry picked from commit 82d88d65f65a0e3eb816cd1ae9d81a0fd78d8a17)
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 2f6bf45d..d0b696c2 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -5886,7 +5886,12 @@ public class ContactsProvider2 extends AbstractContactsProvider
sb.append(")");
qb.appendWhere(sb);
}
- groupBy = Email.DATA + "," + RawContacts.CONTACT_ID;
+
+ // Group by a unique email address on a per account basis, to make sure that
+ // account promotion sort order correctly ranks email addresses that are in
+ // multiple accounts
+ groupBy = Email.DATA + "," + RawContacts.CONTACT_ID + "," +
+ RawContacts.ACCOUNT_NAME + "," + RawContacts.ACCOUNT_TYPE;
if (sortOrder == null) {
final String accountPromotionSortOrder = getAccountPromotionSortOrder(uri);
if (!TextUtils.isEmpty(accountPromotionSortOrder)) {