diff options
author | Victor Chang <vichang@google.com> | 2016-04-20 17:41:04 +0100 |
---|---|---|
committer | Victor Chang <vichang@google.com> | 2016-04-20 17:51:17 +0100 |
commit | c9613fe3972909f3bffb2b235536281bd21bc093 (patch) | |
tree | 03f7779b03f4a8e604622492c0196b041be1064d | |
parent | ef4bb7c1cee29fdbfbb63ef6c60b3b095e57a00c (diff) | |
download | ContactsProvider-c9613fe3972909f3bffb2b235536281bd21bc093.tar.gz |
Fix PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI API
PHOTO_URI can contain 3 types of uris.
ContactsContract.DisplayPhoto.CONTENT_URI (display_photo/#) case was missed.
It happens when PHOTO_FILE_ID is not null.
Added unit test
Bug: 28240255
Change-Id: Ib89de2db4eb7e9cc0b837569b8aa51553aa111fb
-rw-r--r-- | src/com/android/providers/contacts/enterprise/EnterpriseContactsCursorWrapper.java | 3 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/EnterpriseContactsCursorWrapperTest.java | 33 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/com/android/providers/contacts/enterprise/EnterpriseContactsCursorWrapper.java b/src/com/android/providers/contacts/enterprise/EnterpriseContactsCursorWrapper.java index 80dac9a9..4fc4dc85 100644 --- a/src/com/android/providers/contacts/enterprise/EnterpriseContactsCursorWrapper.java +++ b/src/com/android/providers/contacts/enterprise/EnterpriseContactsCursorWrapper.java @@ -202,7 +202,8 @@ public class EnterpriseContactsCursorWrapper extends CursorWrapper { if (uriCode == ContactsProvider2.CONTACTS_ID_PHOTO) { return ContentUris.appendId(Contacts.CORP_CONTENT_URI.buildUpon(), contactId) .appendPath(Contacts.Photo.CONTENT_DIRECTORY).build().toString(); - } else if (uriCode == ContactsProvider2.CONTACTS_ID_DISPLAY_PHOTO) { + } else if (uriCode == ContactsProvider2.CONTACTS_ID_DISPLAY_PHOTO + || uriCode == ContactsProvider2.DISPLAY_PHOTO_ID) { return ContentUris.appendId(Contacts.CORP_CONTENT_URI.buildUpon(), contactId) .appendPath(Contacts.Photo.DISPLAY_PHOTO).build().toString(); } else { diff --git a/tests/src/com/android/providers/contacts/EnterpriseContactsCursorWrapperTest.java b/tests/src/com/android/providers/contacts/EnterpriseContactsCursorWrapperTest.java index 1f72e223..66cebfc9 100644 --- a/tests/src/com/android/providers/contacts/EnterpriseContactsCursorWrapperTest.java +++ b/tests/src/com/android/providers/contacts/EnterpriseContactsCursorWrapperTest.java @@ -153,8 +153,31 @@ public class EnterpriseContactsCursorWrapperTest extends AndroidTestCase { null, // PhoneLookup.NORMALIZED_NUMBER }); + c.addRow(new Object[] { + 13L, // PhoneLookup._ID, + 13L, // PhoneLookup.CONTACT_ID, + null, // PhoneLookup.LOOKUP_KEY, + null, // PhoneLookup.DISPLAY_NAME, + null, // PhoneLookup.LAST_TIME_CONTACTED, + null, // PhoneLookup.TIMES_CONTACTED, + null, // PhoneLookup.STARRED, + null, // PhoneLookup.IN_DEFAULT_DIRECTORY, + null, // PhoneLookup.IN_VISIBLE_GROUP, + 123L, // PhoneLookup.PHOTO_FILE_ID, + null, // PhoneLookup.PHOTO_ID, + "content://com.android.contacts/display_photo/123", // PhoneLookup.PHOTO_URI, + "content://com.android.contacts/contacts/13/photo", // PhoneLookup.PHOTO_THUMBNAIL_URI, + null, // PhoneLookup.CUSTOM_RINGTONE, + null, // PhoneLookup.HAS_PHONE_NUMBER, + null, // PhoneLookup.SEND_TO_VOICEMAIL, + null, // PhoneLookup.NUMBER, + null, // PhoneLookup.TYPE, + null, // PhoneLookup.LABEL, + null, // PhoneLookup.NORMALIZED_NUMBER + }); + rewritten = new EnterpriseContactsCursorWrapper(c, projection, new int[] {0, 1}, null); - assertEquals(4, rewritten.getCount()); + assertEquals(5, rewritten.getCount()); assertEquals(projection.length, rewritten.getColumnCount()); rewritten.moveToFirst(); @@ -222,5 +245,13 @@ public class EnterpriseContactsCursorWrapperTest extends AndroidTestCase { rewritten.getString(11)); assertEquals("content://com.android.contacts/contacts_corp/12/photo", rewritten.getString(12)); + + + // Verify the 5th row. + rewritten.moveToNext(); + assertEquals("content://com.android.contacts/contacts_corp/13/display_photo", + rewritten.getString(11)); + assertEquals("content://com.android.contacts/contacts_corp/13/photo", + rewritten.getString(12)); } } |