diff options
| author | Yorke Lee <yorkelee@google.com> | 2014-01-10 14:15:38 -0800 |
|---|---|---|
| committer | LorDClockaN <davor@losinj.com> | 2014-06-06 22:31:51 +0200 |
| commit | e7ddbbdc17a11066912b4cebe77144a82c072496 (patch) | |
| tree | 7fd6d55eccfcb0ccea72e4a5c5c6cb6cc710d1f3 | |
| parent | 7bcb6f1e28ca706e19e77862afc62e3f7ea27497 (diff) | |
Fix EMAIL_FILTER ranking for duplicate emails in different accounts
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.java | 7 |
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 fbfe73a8..bd76a0cd 100644 --- a/src/com/android/providers/contacts/ContactsProvider2.java +++ b/src/com/android/providers/contacts/ContactsProvider2.java @@ -5889,7 +5889,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)) { |
