summaryrefslogtreecommitdiffstats
path: root/java/com/android/incallui/PhoneLookupHistoryRecorder.java
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-12-12 18:40:11 -0800
committerCopybara-Service <copybara-piper@google.com>2017-12-12 22:51:11 -0800
commita4745bddb3a012c826225df313820ccd8a68455d (patch)
treea3b6f7552bd6e66f28dda2c303249511a498d6be /java/com/android/incallui/PhoneLookupHistoryRecorder.java
parent19be6707405171fdecb86c04f49a7006e2d64057 (diff)
downloadandroid_packages_apps_Dialer-a4745bddb3a012c826225df313820ccd8a68455d.tar.gz
android_packages_apps_Dialer-a4745bddb3a012c826225df313820ccd8a68455d.tar.bz2
android_packages_apps_Dialer-a4745bddb3a012c826225df313820ccd8a68455d.zip
Move TelecomCallUtil to com.android.dialer
Since PhoneLookup exposes Call, more common access to the utility is required. Bug: 70355819 Test: TelecomCallUtilTest PiperOrigin-RevId: 178847628 Change-Id: I6cf55ad4e3566596b7b2e8cffb5a1614e6640a8b
Diffstat (limited to 'java/com/android/incallui/PhoneLookupHistoryRecorder.java')
-rw-r--r--java/com/android/incallui/PhoneLookupHistoryRecorder.java35
1 files changed, 3 insertions, 32 deletions
diff --git a/java/com/android/incallui/PhoneLookupHistoryRecorder.java b/java/com/android/incallui/PhoneLookupHistoryRecorder.java
index 2632e6515..667c0d1cc 100644
--- a/java/com/android/incallui/PhoneLookupHistoryRecorder.java
+++ b/java/com/android/incallui/PhoneLookupHistoryRecorder.java
@@ -19,25 +19,18 @@ import android.content.ContentValues;
import android.content.Context;
import android.support.annotation.Nullable;
import android.telecom.Call;
-import android.telecom.PhoneAccountHandle;
-import android.telephony.PhoneNumberUtils;
-import android.telephony.SubscriptionInfo;
-import android.text.TextUtils;
import com.android.dialer.buildtype.BuildType;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.DialerExecutors;
-import com.android.dialer.location.CountryDetector;
import com.android.dialer.phonelookup.PhoneLookupComponent;
import com.android.dialer.phonelookup.PhoneLookupInfo;
import com.android.dialer.phonelookup.database.contract.PhoneLookupHistoryContract.PhoneLookupHistory;
-import com.android.dialer.telecom.TelecomUtil;
-import com.android.incallui.util.TelecomCallUtil;
+import com.android.dialer.telecom.TelecomCallUtil;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Locale;
/**
* Fetches the current {@link PhoneLookupInfo} for the provided call and writes it to the
@@ -61,7 +54,8 @@ final class PhoneLookupHistoryRecorder {
@Override
public void onSuccess(@Nullable PhoneLookupInfo result) {
Assert.checkArgument(result != null);
- Optional<String> normalizedNumber = getNormalizedNumber(appContext, call);
+ Optional<String> normalizedNumber =
+ TelecomCallUtil.getNormalizedNumber(appContext, call);
if (!normalizedNumber.isPresent()) {
LogUtil.w("PhoneLookupHistoryRecorder.onSuccess", "couldn't get a number");
return;
@@ -90,27 +84,4 @@ final class PhoneLookupHistoryRecorder {
},
DialerExecutors.getLowPriorityThreadPool(appContext));
}
-
- private static Optional<String> getNormalizedNumber(Context appContext, Call call) {
- PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle();
- Optional<SubscriptionInfo> subscriptionInfo =
- TelecomUtil.getSubscriptionInfo(appContext, phoneAccountHandle);
- String countryCode =
- subscriptionInfo.isPresent()
- ? subscriptionInfo.get().getCountryIso()
- : CountryDetector.getInstance(appContext).getCurrentCountryIso();
- if (countryCode == null) {
- LogUtil.w(
- "PhoneLookupHistoryRecorder.getNormalizedNumber",
- "couldn't find a country code for call");
- countryCode = "US";
- }
- String rawNumber = TelecomCallUtil.getNumber(call);
- if (TextUtils.isEmpty(rawNumber)) {
- return Optional.absent();
- }
- String normalizedNumber =
- PhoneNumberUtils.formatNumberToE164(rawNumber, countryCode.toUpperCase(Locale.US));
- return normalizedNumber == null ? Optional.of(rawNumber) : Optional.of(normalizedNumber);
- }
}