From d6302ae725bf1058e24bafef177a7c81384a4662 Mon Sep 17 00:00:00 2001 From: Rohit Yengisetty Date: Tue, 19 Jan 2016 13:47:16 -0800 Subject: Add lookupkey for Contact in ContactBuilder Change-Id: I3271b7c14ef3c61c6f976fcb369c340c1bbaf7bb --- src/com/android/contacts/common/model/ContactBuilder.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/contacts/common/model/ContactBuilder.java b/src/com/android/contacts/common/model/ContactBuilder.java index b40ea26b..9056ff03 100644 --- a/src/com/android/contacts/common/model/ContactBuilder.java +++ b/src/com/android/contacts/common/model/ContactBuilder.java @@ -17,6 +17,7 @@ package com.android.contacts.common.model; import android.content.ContentValues; +import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import com.android.contacts.common.util.CallerMetaData; @@ -74,6 +75,7 @@ public class ContactBuilder { private int mDisplayNameSource = DisplayNameSources.STRUCTURED_NAME; private Uri mPhotoUri; private String mPhotoUrl; + private String mLookupKey; private boolean mIsBusiness; @@ -145,6 +147,14 @@ public class ContactBuilder { } } + // determine the lookup-key for the contact + if (nameObj != null && !TextUtils.isEmpty(mName.displayName)) { + mLookupKey = mName.displayName; + } else if (mPhoneNumbers.size() > 0) { + String number = mPhoneNumbers.get(0).number; + mLookupKey = PhoneNumberUtils.normalizeNumber(number); + } + mSpamCount = contact.optInt(CallerMetaData.SPAM_COUNT, 0); mInfoProviderName = contact.optString(CallerMetaData.INFO_PROVIDER, null); mSuccinctLocation = contact.optString(CallerMetaData.SUCCINCT_LOCATION, null); @@ -387,7 +397,7 @@ public class ContactBuilder { lookupUri, lookupUri, lookupUri, mDirectoryId, - null /* lookupKey */, + mLookupKey, -1 /* id */, -1 /* nameRawContactId */, mDisplayNameSource, -- cgit v1.2.3