summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZheng Fu <zhengfu@google.com>2015-07-07 15:25:28 -0700
committerZheng Fu <zhengfu@google.com>2015-07-07 15:25:28 -0700
commit5ca831dc33dfa16821647e14e377c484df823c80 (patch)
treed8d94b41d182c37a5b20be3dc4653385af405080 /src
parent1d48d5a992c32d37bc9535686d96569680639cfa (diff)
downloadpackages_providers_ContactsProvider-5ca831dc33dfa16821647e14e377c484df823c80.zip
packages_providers_ContactsProvider-5ca831dc33dfa16821647e14e377c484df823c80.tar.gz
packages_providers_ContactsProvider-5ca831dc33dfa16821647e14e377c484df823c80.tar.bz2
Fix bug in aggregation suggestions in new contacts aggregator.
New contact aggregator is using rawContactsMatcher, which is keyed by rawContactId instead of contactId. So we need to remove bestMatches with duplicate contactId for calculating the aggregation suggestions. Bug:22224442 Change-Id: I9e77400a5b09ec28d5bc120706cd4dfe2e296d56
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java b/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java
index 0caa861..cfbad32 100644
--- a/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java
+++ b/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java
@@ -1928,7 +1928,17 @@ public abstract class AbstractContactAggregator {
db.beginTransaction();
try {
List<MatchScore> bestMatches = findMatchingContacts(db, contactId, parameters);
- return queryMatchingContacts(qb, db, projection, bestMatches, maxSuggestions, filter);
+ List<MatchScore> bestMatchesWithoutDuplicateContactIds = new ArrayList<>();
+ Set<Long> contactIds = new HashSet<>();
+ for (MatchScore bestMatch : bestMatches) {
+ long cid = bestMatch.getContactId();
+ if (!contactIds.contains(cid)) {
+ bestMatchesWithoutDuplicateContactIds.add(bestMatch);
+ contactIds.add(cid);
+ }
+ }
+ return queryMatchingContacts(qb, db, projection, bestMatchesWithoutDuplicateContactIds,
+ maxSuggestions, filter);
} finally {
db.endTransaction();
}