Work contacts quick contact badge no longer crashes.
Apperently contact ids are invalid for work contacts, so the URI needs to
exclude them.
Bug: 72755010
Test: manual
PiperOrigin-RevId: 189374262
Change-Id: Ibeaa555dc035e14ea67905c342369188ecfd1832
diff --git a/java/com/android/dialer/searchfragment/directories/DirectoryContactViewHolder.java b/java/com/android/dialer/searchfragment/directories/DirectoryContactViewHolder.java
index f6cdc4f..6e0a05a 100644
--- a/java/com/android/dialer/searchfragment/directories/DirectoryContactViewHolder.java
+++ b/java/com/android/dialer/searchfragment/directories/DirectoryContactViewHolder.java
@@ -130,9 +130,19 @@
}
private static Uri getContactUri(SearchCursor cursor) {
- long contactId = cursor.getLong(Projections.ID);
String lookupKey = cursor.getString(Projections.LOOKUP_KEY);
- return Contacts.getLookupUri(contactId, lookupKey)
+
+ Uri baseUri;
+ // If the contact is a local work contact, leave the contact id out of the uri since it
+ // isn't valid.
+ if (DirectoryCompat.isOnlyEnterpriseDirectoryId(cursor.getDirectoryId())) {
+ baseUri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey);
+ } else {
+ long contactId = cursor.getLong(Projections.ID);
+ baseUri = Contacts.getLookupUri(contactId, lookupKey);
+ }
+
+ return baseUri
.buildUpon()
.appendQueryParameter(
ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(cursor.getDirectoryId()))