summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/telecom
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2018-01-05 11:52:45 -0800
committerEric Erfanian <erfanian@google.com>2018-01-05 11:57:00 -0800
commitfb112d870c3a564d2dcb0e72dcdcabb6e0375520 (patch)
treedbda20e83cb3458fefec613b56d4b9d0a4814e66 /java/com/android/dialer/telecom
parent417be6a9e3482472cce238e0a51b6367b86aba1f (diff)
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
Diffstat (limited to 'java/com/android/dialer/telecom')
-rw-r--r--java/com/android/dialer/telecom/TelecomCallUtil.java23
1 files changed, 15 insertions, 8 deletions
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<String> getE164Number(Context appContext, Call call) {
Assert.isWorkerThread();
- PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle();
- Optional<SubscriptionInfo> 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<String> 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<String> getCountryCode(Context appContext, Call call) {
+ Assert.isWorkerThread();
+ PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle();
+ Optional<SubscriptionInfo> subscriptionInfo =
+ TelecomUtil.getSubscriptionInfo(appContext, phoneAccountHandle);
+ if (subscriptionInfo.isPresent() && subscriptionInfo.get().getCountryIso() != null) {
+ return Optional.of(subscriptionInfo.get().getCountryIso().toUpperCase(Locale.US));
+ }
+ return Optional.absent();
}
}