From 7982723ff5c03ec71c2dc3cc740af239fc327a47 Mon Sep 17 00:00:00 2001 From: twyen Date: Tue, 29 May 2018 14:12:58 -0700 Subject: Use geocode as label for businesses. Business number from PhoneNumberService does not always have a sensible label. Previously it would be "Main", but geocode are a bit more useful. TEST=manual, old UI has no tests. Bug: 80251984 Test: manual, old UI has no tests. PiperOrigin-RevId: 198455846 Change-Id: I5efbc66aa295f8039eecfbcb119f18afc735b15c --- .../android/dialer/app/calllog/PhoneCallDetailsHelper.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'java/com/android/dialer/app') diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java index 2632fb380..9d04cb2c8 100644 --- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java +++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java @@ -48,6 +48,8 @@ import com.android.dialer.compat.android.provider.VoicemailCompat; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.logging.ContactSource; import com.android.dialer.oem.MotorolaUtils; +import com.android.dialer.phonenumbercache.CachedNumberLookupService; +import com.android.dialer.phonenumbercache.PhoneNumberCache; import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.spannable.ContentWithLearnMoreSpanner; import com.android.dialer.storage.StorageComponent; @@ -76,6 +78,8 @@ public class PhoneCallDetailsHelper private final CallLogCache callLogCache; /** Calendar used to construct dates */ private final Calendar calendar; + + private final CachedNumberLookupService cachedNumberLookupService; /** The injected current time in milliseconds since the epoch. Used only by tests. */ private Long currentTimeMillisForTest; @@ -95,6 +99,7 @@ public class PhoneCallDetailsHelper this.resources = resources; this.callLogCache = callLogCache; calendar = Calendar.getInstance(); + cachedNumberLookupService = PhoneNumberCache.get(context).getCachedNumberLookupService(); } static boolean shouldShowVoicemailDonationPromo( @@ -125,7 +130,7 @@ public class PhoneCallDetailsHelper } /** Returns true if primary name is empty or the data is from Cequint Caller ID. */ - private static boolean shouldShowLocation(PhoneCallDetails details) { + private boolean shouldShowLocation(PhoneCallDetails details) { if (TextUtils.isEmpty(details.geocode)) { return false; } @@ -133,6 +138,11 @@ public class PhoneCallDetailsHelper if (details.sourceType == ContactSource.Type.SOURCE_TYPE_CEQUINT_CALLER_ID) { return true; } + if (cachedNumberLookupService != null + && cachedNumberLookupService.isBusiness(details.sourceType)) { + return true; + } + // Don't bother showing geo location for contacts. if (!TextUtils.isEmpty(details.namePrimary)) { return false; @@ -482,7 +492,6 @@ public class PhoneCallDetailsHelper : Phone.getTypeLabel(resources, details.numberType, details.numberLabel); } } - if (!TextUtils.isEmpty(details.namePrimary) && TextUtils.isEmpty(numberFormattedLabel)) { numberFormattedLabel = details.displayNumber; } -- cgit v1.2.3