diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-08-25 14:29:27 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-25 14:29:27 -0700 |
commit | d263c073c3697aa3e58a8ef73096b8ff7012f8ea (patch) | |
tree | f73c21e3259701555db5a274f6a6074b08d76740 | |
parent | 9b002837367674b7403769f52dc50ab4dbecef71 (diff) | |
parent | cf55cbe8932f620484a3634d13ecc116c32fdc99 (diff) | |
download | packages_providers_ContactsProvider-d263c073c3697aa3e58a8ef73096b8ff7012f8ea.zip packages_providers_ContactsProvider-d263c073c3697aa3e58a8ef73096b8ff7012f8ea.tar.gz packages_providers_ContactsProvider-d263c073c3697aa3e58a8ef73096b8ff7012f8ea.tar.bz2 |
Merge "Group rows with a same phone number and a contact id."
-rw-r--r-- | src/com/android/providers/contacts/ContactsProvider2.java | 1 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactsProvider2Test.java | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java index a8ffab1..d7e97fd 100644 --- a/src/com/android/providers/contacts/ContactsProvider2.java +++ b/src/com/android/providers/contacts/ContactsProvider2.java @@ -5030,6 +5030,7 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun case PHONES: { setTablesAndProjectionMapForData(qb, uri, projection, false); qb.appendWhere(" AND " + Data.MIMETYPE + " = '" + Phone.CONTENT_ITEM_TYPE + "'"); + groupBy = RawContacts.CONTACT_ID + ", " + Data.DATA1; break; } diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java index e14e21c..fd4e188 100644 --- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java @@ -891,6 +891,32 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { assertSelection(Phone.CONTENT_URI, values, Data._ID, phoneId); } + public void testPhonesWithMergedContacts() { + long rawContactId1 = createRawContact(); + insertPhoneNumber(rawContactId1, "123456789", true); + + long rawContactId2 = createRawContact(); + insertPhoneNumber(rawContactId2, "123456789", true); + + ContentValues values1 = new ContentValues(); + values1.put(Contacts.DISPLAY_NAME, "123456789"); + values1.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); + values1.put(Phone.NUMBER, "123456789"); + + // Two results should come, since they are separate entries anyway. + assertStoredValues(Phone.CONTENT_URI, new ContentValues[] {values1, values1}); + + setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER, + rawContactId1, rawContactId2); + + assertAggregated(rawContactId1, rawContactId2, "123456789"); + + // Just one result should come, since + // - those two numbers have the same phone number + // - those two contacts are aggregated + assertStoredValues(Phone.CONTENT_URI, values1); + } + public void testPhonesFilterQuery() { long rawContactId1 = createRawContactWithName("Hot", "Tamale", ACCOUNT_1); insertPhoneNumber(rawContactId1, "1-800-466-4411"); |