summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/telecom
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2018-03-16 12:40:07 -0700
committerCopybara-Service <copybara-piper@google.com>2018-03-16 12:43:06 -0700
commit73ae7522a6d9faca76f24b94e3bb3e2088e5f74f (patch)
tree73969f4f879b3919944241f6dfc6a83346c06fec /java/com/android/dialer/telecom
parent262b6f2355b93d0e282d39ef16d222a65d450d16 (diff)
Use current county ISO for PhoneLookupHistoryRecorder
Previously it is unclear what the "county ISO" should be so the originating county of the SIM is used. When telecom writes to the call log the county the user is in is used. This caused the DialerPhoneNumber key in in call UI and call log to differ and info to be lost. In this CL, the current country is used in PhoneLookupHistoryRecorder to make it consistent with the call log. PhoneLookupHistoryRecorder is currently the only consumer for telecom call util.getCountryCode(). Additionally, dialer/location no longer depends on dialer/util. dialer/util has too many unnecessary dependencies that will cause cycles. Bug: 73752730 Test: Unit tests PiperOrigin-RevId: 189378542 Change-Id: I59773f7745c835a6523efda951c475e2fde9aaf9
Diffstat (limited to 'java/com/android/dialer/telecom')
-rw-r--r--java/com/android/dialer/telecom/TelecomCallUtil.java43
1 files changed, 13 insertions, 30 deletions
diff --git a/java/com/android/dialer/telecom/TelecomCallUtil.java b/java/com/android/dialer/telecom/TelecomCallUtil.java
index 3ae952357..6b66d868e 100644
--- a/java/com/android/dialer/telecom/TelecomCallUtil.java
+++ b/java/com/android/dialer/telecom/TelecomCallUtil.java
@@ -22,14 +22,11 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import android.telecom.Call;
-import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
-import android.telephony.SubscriptionInfo;
import android.text.TextUtils;
import com.android.dialer.common.Assert;
-import com.android.dialer.common.LogUtil;
+import com.android.dialer.location.GeoUtil;
import com.google.common.base.Optional;
-import java.util.Locale;
/**
* Class to provide a standard interface for obtaining information from the underlying
@@ -72,11 +69,12 @@ public class TelecomCallUtil {
}
/**
- * Normalizes the number of the {@code call} to E.164. The country of the SIM associated with the
- * call is used to determine the country.
+ * Normalizes the number of the {@code call} to E.164. If the number for the call does not contain
+ * a country code, then the current location as defined by {@link
+ * GeoUtil#getCurrentCountryIso(Context)} is used.
*
- * <p>If the number cannot be formatted (because for example the country cannot be determined),
- * returns the number with non-dialable digits removed.
+ * <p>If the number cannot be formatted (because for example number is invalid), returns the
+ * number with non-dialable digits removed.
*/
@WorkerThread
public static Optional<String> getNormalizedNumber(Context appContext, Call call) {
@@ -94,11 +92,12 @@ public class TelecomCallUtil {
}
/**
- * Formats the number of the {@code call} to E.164 if it is valid. The country of the SIM
- * associated with the call is used to determine the country.
+ * Formats the number of the {@code call} to E.164 if it is valid. If the number for the call does
+ * not contain a country code, then the current location as defined by {@link
+ * GeoUtil#getCurrentCountryIso(Context)} is used.
*
- * <p>If the number cannot be formatted (because for example it is invalid or the country cannot
- * be determined), returns {@link Optional#absent()}.
+ * <p>If the number cannot be formatted (because for example it is invalid), returns {@link
+ * Optional#absent()}.
*/
@WorkerThread
public static Optional<String> getValidE164Number(Context appContext, Call call) {
@@ -107,23 +106,7 @@ public class TelecomCallUtil {
if (TextUtils.isEmpty(rawNumber)) {
return Optional.absent();
}
- Optional<String> countryCode = getCountryCode(appContext, call);
- if (!countryCode.isPresent()) {
- LogUtil.w("TelecomCallUtil.getValidE164Number", "couldn't find a country code for call");
- return Optional.absent();
- }
- 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();
+ return Optional.fromNullable(
+ PhoneNumberUtils.formatNumberToE164(rawNumber, GeoUtil.getCurrentCountryIso(appContext)));
}
}