From a4745bddb3a012c826225df313820ccd8a68455d Mon Sep 17 00:00:00 2001 From: twyen Date: Tue, 12 Dec 2017 18:40:11 -0800 Subject: 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 --- .../incallui/PhoneLookupHistoryRecorder.java | 35 ++-------------------- 1 file changed, 3 insertions(+), 32 deletions(-) (limited to 'java/com/android/incallui/PhoneLookupHistoryRecorder.java') 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 normalizedNumber = getNormalizedNumber(appContext, call); + Optional 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 getNormalizedNumber(Context appContext, Call call) { - PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle(); - Optional 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); - } } -- cgit v1.2.3