From fb112d870c3a564d2dcb0e72dcdcabb6e0375520 Mon Sep 17 00:00:00 2001 From: twyen Date: Fri, 5 Jan 2018 11:52:45 -0800 Subject: Implement dialer blocked number phone lookup This CL implements looking up the dialer internal database for blocked numbers when the system database is not available yet. Data is only invalidated when dialer is alive since that is the only time blocked numbers can be set and removed. Bug: 70989538,70989547 Test: DialerBlockedNumberPhoneLookupTest PiperOrigin-RevId: 180956355 Change-Id: Ie7acf091bf58a074d0a1ee39613fad035d2e6e60 --- .../android/dialer/telecom/TelecomCallUtil.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'java/com/android/dialer/telecom') diff --git a/java/com/android/dialer/telecom/TelecomCallUtil.java b/java/com/android/dialer/telecom/TelecomCallUtil.java index b877a7392..7d71b4b90 100644 --- a/java/com/android/dialer/telecom/TelecomCallUtil.java +++ b/java/com/android/dialer/telecom/TelecomCallUtil.java @@ -103,20 +103,27 @@ public class TelecomCallUtil { @WorkerThread public static Optional getE164Number(Context appContext, Call call) { Assert.isWorkerThread(); - PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle(); - Optional subscriptionInfo = - TelecomUtil.getSubscriptionInfo(appContext, phoneAccountHandle); String rawNumber = getNumber(call); if (TextUtils.isEmpty(rawNumber)) { return Optional.absent(); } - String countryCode = - subscriptionInfo.isPresent() ? subscriptionInfo.get().getCountryIso() : null; - if (countryCode == null) { + Optional countryCode = getCountryCode(appContext, call); + if (!countryCode.isPresent()) { LogUtil.w("TelecomCallUtil.getE164Number", "couldn't find a country code for call"); return Optional.absent(); } - return Optional.fromNullable( - PhoneNumberUtils.formatNumberToE164(rawNumber, countryCode.toUpperCase(Locale.US))); + return Optional.fromNullable(PhoneNumberUtils.formatNumberToE164(rawNumber, countryCode.get())); + } + + @WorkerThread + public static Optional getCountryCode(Context appContext, Call call) { + Assert.isWorkerThread(); + PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle(); + Optional subscriptionInfo = + TelecomUtil.getSubscriptionInfo(appContext, phoneAccountHandle); + if (subscriptionInfo.isPresent() && subscriptionInfo.get().getCountryIso() != null) { + return Optional.of(subscriptionInfo.get().getCountryIso().toUpperCase(Locale.US)); + } + return Optional.absent(); } } -- cgit v1.2.3