aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng Fu <zhengfu@google.com>2014-11-13 12:07:24 -0800
committerZheng Fu <zhengfu@google.com>2014-11-13 12:07:24 -0800
commitdf1e589415a68f4427219459ced28638d382132b (patch)
treeaae17cdfd4f646c0954c60b5c8db4066947f0dda
parent77e675b050770c1bd68906c25859d7cdf8ea49db (diff)
downloadContactsProvider-df1e589415a68f4427219459ced28638d382132b.tar.gz
Make the email comparison case-insensitive for contact aggregation.
Bug:18304324 Change-Id: If9e11022e392323b770c7560eba69617769ca080
-rw-r--r--src/com/android/providers/contacts/aggregation/ContactAggregator.java4
-rw-r--r--tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java14
2 files changed, 14 insertions, 4 deletions
diff --git a/src/com/android/providers/contacts/aggregation/ContactAggregator.java b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
index e4044c2b..ed73114d 100644
--- a/src/com/android/providers/contacts/aggregation/ContactAggregator.java
+++ b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
@@ -930,7 +930,7 @@ public class ContactAggregator {
"SELECT count(*)" +
" FROM " + Tables.DATA + " AS d1" +
" JOIN " + Tables.DATA + " AS d2"
- + " ON (d1." + Email.ADDRESS + " = d2." + Email.ADDRESS + ")" +
+ + " ON lower(d1." + Email.ADDRESS + ") = lower(d2." + Email.ADDRESS + ")" +
" WHERE d1." + DataColumns.MIMETYPE_ID + " = ?1" +
" AND d2." + DataColumns.MIMETYPE_ID + " = ?1" +
" AND d1." + Data.RAW_CONTACT_ID + " = ?2" +
@@ -1616,7 +1616,7 @@ public class ContactAggregator {
private interface EmailLookupQuery {
String TABLE = Tables.DATA + " dataA"
+ " JOIN " + Tables.DATA + " dataB" +
- " ON (" + "dataA." + Email.DATA + "=dataB." + Email.DATA + ")"
+ " ON lower(" + "dataA." + Email.DATA + ")=lower(dataB." + Email.DATA + ")"
+ " JOIN " + Tables.RAW_CONTACTS +
" ON (dataB." + Data.RAW_CONTACT_ID + " = "
+ Tables.RAW_CONTACTS + "." + RawContacts._ID + ")";
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
index 6ce98a72..763247cf 100644
--- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
+++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
@@ -766,7 +766,7 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
assertNotAggregated(rawContactId1, rawContactId2);
}
- public void testAggregationFromSameAccountEmailSame() {
+ public void testAggregationFromSameAccountEmailSame_IgnoreCase() {
long rawContactId1 = RawContactUtil.createRawContactWithName(mResolver, "John", "Doe",
ACCOUNT_1);
insertEmail(rawContactId1, "lightning@android.com");
@@ -776,6 +776,16 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
insertEmail(rawContactId2, "lightning@android.com");
assertAggregated(rawContactId1, rawContactId2);
+
+ long rawContactId3 = RawContactUtil.createRawContactWithName(mResolver, "Jane", "Doe",
+ ACCOUNT_1);
+ insertEmail(rawContactId3, "jane@android.com");
+
+ long rawContactId4 = RawContactUtil.createRawContactWithName(mResolver, "Jane", "Doe",
+ ACCOUNT_1);
+ insertEmail(rawContactId4, "JANE@ANDROID.COM");
+
+ assertAggregated(rawContactId3, rawContactId4);
}
public void testNonAggregationFromSameAccountEmailDifferent() {
@@ -905,7 +915,7 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
long rawContactId2 = RawContactUtil.createRawContact(mResolver);
DataUtil.insertStructuredName(mResolver, rawContactId2, "Charles", "Muntz");
- insertEmail(rawContactId2, "up@android.com");
+ insertEmail(rawContactId2, "Up@Android.com");
long contactId1 = queryContactId(rawContactId1);
long contactId2 = queryContactId(rawContactId2);