Reconcile with jb-mr0-release
Change-Id: I7d9679502b2d27db916d3e4e30af26db326835da
diff --git a/Android.mk b/Android.mk
index 634ef9f..df4d245 100644
--- a/Android.mk
+++ b/Android.mk
@@ -8,7 +8,7 @@
LOCAL_SRC_FILES += \
src/com/android/providers/contacts/EventLogTags.logtags
-LOCAL_JAVA_LIBRARIES := ext
+LOCAL_JAVA_LIBRARIES := ext telephony-common
LOCAL_STATIC_JAVA_LIBRARIES += android-common com.android.vcard guava
diff --git a/src/com/android/providers/contacts/aggregation/ContactAggregator.java b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
index 6ad93c9..d3931e6 100644
--- a/src/com/android/providers/contacts/aggregation/ContactAggregator.java
+++ b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
@@ -791,6 +791,10 @@
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/CallLogProviderTest.java b/tests/src/com/android/providers/contacts/CallLogProviderTest.java
index 02aebb7..05f8c25 100644
--- a/tests/src/com/android/providers/contacts/CallLogProviderTest.java
+++ b/tests/src/com/android/providers/contacts/CallLogProviderTest.java
@@ -17,7 +17,7 @@
package com.android.providers.contacts;
import com.android.internal.telephony.CallerInfo;
-import com.android.internal.telephony.Connection;
+import com.android.internal.telephony.PhoneConstants;
import android.content.ContentProvider;
import android.content.ContentUris;
@@ -180,7 +180,7 @@
ci.numberType = Phone.TYPE_CUSTOM;
ci.numberLabel = "Directory";
Uri uri = Calls.addCall(ci, getMockContext(), "1-800-263-7643",
- Connection.PRESENTATION_ALLOWED, Calls.OUTGOING_TYPE, 2000, 40);
+ PhoneConstants.PRESENTATION_ALLOWED, Calls.OUTGOING_TYPE, 2000, 40);
ContentValues values = new ContentValues();
values.put(Calls.TYPE, Calls.OUTGOING_TYPE);
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
index 8de5890..795ea9c 100644
--- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
+++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
@@ -537,6 +537,42 @@
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);
@@ -1413,4 +1449,18 @@
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);
+ }
}