diff options
author | zachh <zachh@google.com> | 2018-05-22 12:02:31 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-22 15:31:44 -0700 |
commit | 0956d35903f49a3985a05fd7ea64869555d477b3 (patch) | |
tree | b58bf9561e7f566a2b6ad53f2cee3159c7bae72f /java/com/android/dialer/phonelookup/cp2/Cp2Projections.java | |
parent | e10f20f6b8e568d89ab36d26df05282a0c4512b3 (diff) |
Append the directory ID when building contact lookup URIs in CP2 lookups.
Before, when tapping the icon in the call log for a call made to a remote contact, I would get a "Contact doesn't exist" message because CP2 couldn't find the contact due to:
05-18 22:28:48.750 E/DatabaseUtils(26187): java.lang.IllegalArgumentException: Invalid lookup id: people-v2:114584120460114609902
05-18 22:28:48.750 E/DatabaseUtils(26187): at com.android.providers.contacts.ContactLookupKey.parse(ContactLookupKey.java:157)
05-18 22:28:48.750 E/DatabaseUtils(26187): at com.android.providers.contacts.ContactsProvider2.lookupContactIdByLookupKey(ContactsProvider2.java:7766)
05-18 22:28:48.750 E/DatabaseUtils(26187): at com.android.providers.contacts.ContactsProvider2.queryLocal(ContactsProvider2.java:6248)
05-18 22:28:48.750 E/DatabaseUtils(26187): at com.android.providers.contacts.ContactsProvider2.queryDirectoryIfNecessary(ContactsProvider2.java:5565)
05-18 22:28:48.750 E/DatabaseUtils(26187): at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:5544)
05-18 22:28:48.750 E/DatabaseUtils(26187): at android.content.ContentProvider.query(ContentProvider.java:1147)
05-18 22:28:48.750 E/DatabaseUtils(26187): at android.content.ContentProvider$Transport.query(ContentProvider.java:240)
05-18 22:28:48.750 E/DatabaseUtils(26187): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:102)
05-18 22:28:48.750 E/DatabaseUtils(26187): at android.os.Binder.execTransact(Binder.java:697)
When we construct the contact URI in Cp2ExtendedDirectoryPhoneLookup, we should include the directory ID so that CP2 knows where to look when the user taps the icon in the call log.
TEST=unit, manual
Bug: 80008014
Test: unit, manual
PiperOrigin-RevId: 197600727
Change-Id: Ib262ca4b7e605c3e94ea683289f62c727389b32f
Diffstat (limited to 'java/com/android/dialer/phonelookup/cp2/Cp2Projections.java')
-rw-r--r-- | java/com/android/dialer/phonelookup/cp2/Cp2Projections.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java b/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java index 377091264..38390e559 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2Projections.java @@ -18,6 +18,7 @@ package com.android.dialer.phonelookup.cp2; import android.content.Context; import android.database.Cursor; +import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.PhoneLookup; @@ -85,7 +86,8 @@ final class Cp2Projections { * Builds a {@link Cp2ContactInfo} based on the current row of {@code cursor}, of which the * projection is either {@link #PHONE_PROJECTION} or {@link #PHONE_LOOKUP_PROJECTION}. */ - static Cp2ContactInfo buildCp2ContactInfoFromCursor(Context appContext, Cursor cursor) { + static Cp2ContactInfo buildCp2ContactInfoFromCursor( + Context appContext, Cursor cursor, long directoryId) { String displayName = cursor.getString(CP2_INFO_NAME_INDEX); String photoThumbnailUri = cursor.getString(CP2_INFO_PHOTO_THUMBNAIL_URI_INDEX); String photoUri = cursor.getString(CP2_INFO_PHOTO_URI_INDEX); @@ -116,7 +118,13 @@ final class Cp2Projections { } infoBuilder.setContactId(contactId); if (!TextUtils.isEmpty(lookupKey)) { - infoBuilder.setLookupUri(Contacts.getLookupUri(contactId, lookupKey).toString()); + infoBuilder.setLookupUri( + Contacts.getLookupUri(contactId, lookupKey) + .buildUpon() + .appendQueryParameter( + ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)) + .build() + .toString()); } // Only PHONE_PROJECTION has a column containing carrier presence info. |