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
1 file changed