aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2012-06-13 12:54:57 -0700
committerandroid code review <noreply-gerritcodereview@google.com>2012-06-13 12:54:57 -0700
commita499a2adb856223de65d298cd93d70c85afe3d4d (patch)
tree19c05d1f7c88913c24817f38082ae377a390c944
parent7f2bbd3bbe2a7159854a8c037433b9ec4ad35ccb (diff)
parent323c20f313689a71f716513f9ea772e992cbd59f (diff)
downloadContactsProvider-tools_r20.tar.gz
Merge "Fix aggregation exception problem"android-sdk-adt_r20tools_r20ics-plus-aosp
-rw-r--r--src/com/android/providers/contacts/ContactAggregator.java4
-rw-r--r--tests/src/com/android/providers/contacts/ContactAggregatorTest.java50
2 files changed, 54 insertions, 0 deletions
diff --git a/src/com/android/providers/contacts/ContactAggregator.java b/src/com/android/providers/contacts/ContactAggregator.java
index cad5d50e..9b4ecd9e 100644
--- a/src/com/android/providers/contacts/ContactAggregator.java
+++ b/src/com/android/providers/contacts/ContactAggregator.java
@@ -728,6 +728,10 @@ public class ContactAggregator {
mContactUpdate.execute();
mDbHelper.updateContactVisible(txContext, contactId);
updateAggregatedStatusUpdate(contactId);
+ // Make sure the raw contact does not contribute to the current contact
+ if (currentContactId != 0) {
+ updateAggregateData(txContext, currentContactId);
+ }
}
if (contactIdToSplit != -1) {
diff --git a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java
index 5c7c0ff8..268bcb43 100644
--- a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java
+++ b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java
@@ -541,6 +541,42 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
assertEquals("Johnm Smithm", displayName4);
}
+ public void testAggregationExceptionKeepOutCheckResultDisplayNames() {
+ long rawContactId1 = createRawContactWithName("c", "c", ACCOUNT_1);
+ long rawContactId2 = createRawContactWithName("b", "b", ACCOUNT_2);
+ long rawContactId3 = createRawContactWithName("a", "a", ACCOUNT_3);
+
+ // Join all contacts
+ setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER,
+ rawContactId1, rawContactId2);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER,
+ rawContactId1, rawContactId3);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER,
+ rawContactId2, rawContactId3);
+
+ // Separate all contacts. The order (2-3 , 1-2, 1-3) is important
+ setAggregationException(AggregationExceptions.TYPE_KEEP_SEPARATE,
+ rawContactId2, rawContactId3);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_SEPARATE,
+ rawContactId1, rawContactId2);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_SEPARATE,
+ rawContactId1, rawContactId3);
+
+ // Verify that we have three different contacts
+ long contactId1 = queryContactId(rawContactId1);
+ long contactId2 = queryContactId(rawContactId2);
+ long contactId3 = queryContactId(rawContactId3);
+
+ assertTrue(contactId1 != contactId2);
+ assertTrue(contactId1 != contactId3);
+ assertTrue(contactId2 != contactId3);
+
+ // Verify that each raw contact contribute to the contact display name
+ assertDisplayNameEquals(contactId1, rawContactId1);
+ assertDisplayNameEquals(contactId2, rawContactId2);
+ assertDisplayNameEquals(contactId3, rawContactId3);
+ }
+
public void testNonAggregationWithMultipleAffinities() {
long rawContactId1 = createRawContactWithName("John", "Doe", ACCOUNT_1);
long rawContactId2 = createRawContactWithName("John", "Doe", ACCOUNT_1);
@@ -1288,4 +1324,18 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
cursor.close();
}
+
+ private void assertDisplayNameEquals(long contactId, long rawContactId) {
+
+ String contactDisplayName = queryDisplayName(contactId);
+
+ Cursor c = queryRawContact(rawContactId);
+ assertTrue(c.moveToFirst());
+ String rawDisplayName = c.getString(c.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY));
+ c.close();
+
+ assertTrue(contactDisplayName != null);
+ assertTrue(rawDisplayName != null);
+ assertEquals(rawDisplayName, contactDisplayName);
+ }
}