summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZheng Fu <zhengfu@google.com>2014-12-09 23:34:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-12-09 23:34:36 +0000
commitbecda5cc4e265ab2cc3fc958e39de08380abd6c3 (patch)
tree142a81052b0f2eb122fbbc9c20fcd2ad925cf5b8 /src
parenteb10c527fcd100d485f2d27a8a1ffea585960802 (diff)
parent085a7471448168069dac091eeb8a1c5e76138ffb (diff)
downloadpackages_providers_ContactsProvider-becda5cc4e265ab2cc3fc958e39de08380abd6c3.zip
packages_providers_ContactsProvider-becda5cc4e265ab2cc3fc958e39de08380abd6c3.tar.gz
packages_providers_ContactsProvider-becda5cc4e265ab2cc3fc958e39de08380abd6c3.tar.bz2
Merge "Skip aggregation if candidate contact contains too many raw contacts" into lmp-mr1-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/contacts/aggregation/ContactAggregator.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/com/android/providers/contacts/aggregation/ContactAggregator.java b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
index ce2c50a..8dcabca 100644
--- a/src/com/android/providers/contacts/aggregation/ContactAggregator.java
+++ b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
@@ -136,6 +136,12 @@ public class ContactAggregator {
private static final int SECONDARY_HIT_LIMIT = 20;
private static final String SECONDARY_HIT_LIMIT_STRING = String.valueOf(SECONDARY_HIT_LIMIT);
+ // If we encounter no less than this many raw contacts in the best matching contact during
+ // aggregation, don't attempt to aggregate - this is likely an error or a shared corporate
+ // data element.
+ @VisibleForTesting
+ static final int AGGREGATION_CONTACT_SIZE_LIMIT = 50;
+
// If we encounter more than this many contacts with matching name during aggregation
// suggestion lookup, ignore the remaining results.
private static final int FIRST_LETTER_SUGGESTION_HIT_LIMIT = 100;
@@ -789,8 +795,19 @@ public class ContactAggregator {
} finally {
rawContactsToAccountsCursor.close();
}
- final int actionCode = canJoinIntoContact(db, rawContactId,
- rawContactIdsInSameAccount, rawContactIdsInOtherAccount);
+ final int actionCode;
+ final int totalNumOfRawContactsInCandidate = rawContactIdsInSameAccount.size()
+ + rawContactIdsInOtherAccount.size();
+ if (totalNumOfRawContactsInCandidate >= AGGREGATION_CONTACT_SIZE_LIMIT) {
+ if (VERBOSE_LOGGING) {
+ Log.v(TAG, "Too many raw contacts (" + totalNumOfRawContactsInCandidate
+ + ") in the best matching contact, so skip aggregation");
+ }
+ actionCode = KEEP_SEPARATE;
+ } else {
+ actionCode = canJoinIntoContact(db, rawContactId,
+ rawContactIdsInSameAccount, rawContactIdsInOtherAccount);
+ }
if (actionCode == KEEP_SEPARATE) {
contactId = -1;
} else if (actionCode == RE_AGGREGATE) {