From 2ca4318cc1ee57dda907ba2069bd61d162b1baef Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 31 Aug 2017 06:57:16 -0700 Subject: Update Dialer source to latest internal Google revision. Previously, Android's Dialer app was developed in an internal Google source control system and only exported to public during AOSP drops. The Dialer team is now switching to a public development model similar to the telephony team. This CL represents all internal Google changes that were committed to Dialer between the public O release and today's tip of tree on internal master. This CL squashes those changes into a single commit. In subsequent changes, changes will be exported on a per-commit basis. Test: make, flash install, run Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160 Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8 PiperOrigin-RevId: 167068436 --- .../dialer/phonenumbercache/ContactInfoHelper.java | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'java/com/android/dialer/phonenumbercache/ContactInfoHelper.java') diff --git a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java index bd4ba9764..b680bd57d 100644 --- a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java +++ b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java @@ -38,7 +38,6 @@ import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.ContactsUtils.UserType; import com.android.contacts.common.compat.DirectoryCompat; import com.android.contacts.common.util.Constants; -import com.android.contacts.common.util.UriUtils; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.logging.ContactSource; @@ -48,6 +47,7 @@ import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedConta import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.PermissionsUtil; +import com.android.dialer.util.UriUtils; import java.util.ArrayList; import java.util.List; import org.json.JSONException; @@ -203,6 +203,7 @@ public class ContactInfoHelper { return info; } + @Nullable public ContactInfo lookupNumber(String number, String countryIso) { return lookupNumber(number, countryIso, -1); } @@ -223,12 +224,14 @@ public class ContactInfoHelper { @SuppressWarnings("ReferenceEquality") public ContactInfo lookupNumber(String number, String countryIso, long directoryId) { if (TextUtils.isEmpty(number)) { + LogUtil.d("ContactInfoHelper.lookupNumber", "number is empty"); return null; } ContactInfo info; if (PhoneNumberHelper.isUriNumber(number)) { + LogUtil.d("ContactInfoHelper.lookupNumber", "number is sip"); // The number is a SIP address.. info = lookupContactFromUri(getContactInfoLookupUri(number, directoryId)); if (info == null || info == ContactInfo.EMPTY) { @@ -246,6 +249,7 @@ public class ContactInfoHelper { final ContactInfo updatedInfo; if (info == null) { // The lookup failed. + LogUtil.d("ContactInfoHelper.lookupNumber", "lookup failed"); updatedInfo = null; } else { // If we did not find a matching contact, generate an empty contact info for the number. @@ -325,9 +329,11 @@ public class ContactInfoHelper { */ ContactInfo lookupContactFromUri(Uri uri) { if (uri == null) { + LogUtil.d("ContactInfoHelper.lookupContactFromUri", "uri is null"); return null; } if (!PermissionsUtil.hasContactsReadPermissions(mContext)) { + LogUtil.d("ContactInfoHelper.lookupContactFromUri", "no contact permission, return empty"); return ContactInfo.EMPTY; } @@ -336,10 +342,12 @@ public class ContactInfoHelper { String[] projection = PhoneQuery.getPhoneLookupProjection(uri); phoneLookupCursor = mContext.getContentResolver().query(uri, projection, null, null, null); } catch (NullPointerException e) { + LogUtil.e("ContactInfoHelper.lookupContactFromUri", "phone lookup", e); // Trap NPE from pre-N CP2 return null; } if (phoneLookupCursor == null) { + LogUtil.d("ContactInfoHelper.lookupContactFromUri", "phoneLookupCursor is null"); return null; } @@ -408,19 +416,32 @@ public class ContactInfoHelper { private ContactInfo queryContactInfoForPhoneNumber( String number, String countryIso, long directoryId) { if (TextUtils.isEmpty(number)) { + LogUtil.d("ContactInfoHelper.queryContactInfoForPhoneNumber", "number is empty"); return null; } ContactInfo info = lookupContactFromUri(getContactInfoLookupUri(number, directoryId)); + if (info == null) { + LogUtil.d("ContactInfoHelper.queryContactInfoForPhoneNumber", "info looked up is null"); + } if (info != null && info != ContactInfo.EMPTY) { info.formattedNumber = formatPhoneNumber(number, null, countryIso); + if (directoryId == -1) { + // Contact found in the default directory + info.sourceType = ContactSource.Type.SOURCE_TYPE_DIRECTORY; + } else { + // Contact found in the extended directory specified by directoryId + info.sourceType = ContactSource.Type.SOURCE_TYPE_EXTENDED; + } } else if (mCachedNumberLookupService != null) { CachedContactInfo cacheInfo = mCachedNumberLookupService.lookupCachedContactFromNumber(mContext, number); if (cacheInfo != null) { - info = cacheInfo.getContactInfo().isBadData ? null : cacheInfo.getContactInfo(); - } else { - info = null; + if (!cacheInfo.getContactInfo().isBadData) { + info = cacheInfo.getContactInfo(); + } else { + LogUtil.i("ContactInfoHelper.queryContactInfoForPhoneNumber", "info is bad data"); + } } } return info; @@ -601,13 +622,17 @@ public class ContactInfoHelper { * will be updated if available. */ @WorkerThread - public void updateFromCequintCallerId(ContactInfo info, String number) { + public void updateFromCequintCallerId( + @Nullable CequintCallerIdManager cequintCallerIdManager, ContactInfo info, String number) { Assert.isWorkerThread(); if (!CequintCallerIdManager.isCequintCallerIdEnabled(mContext)) { return; } + if (cequintCallerIdManager == null) { + return; + } CequintCallerIdContact cequintCallerIdContact = - CequintCallerIdManager.getCequintCallerIdContact(mContext, number); + cequintCallerIdManager.getCequintCallerIdContact(mContext, number); if (cequintCallerIdContact == null) { return; } -- cgit v1.2.3