Better handling country iso when getting geo location of phone number.
1. Use existing country iso info instead of guessing current country iso from sim and locale for blocked number.
2. Use country iso of current sim instead of default sim for incall location info. This fixes bug in multi sim device when default sim is out of service and making call with the other sim.
Bug: 65399976
Test: manual
PiperOrigin-RevId: 169554641
Change-Id: I416d7e2d6bc3c872bfec3eda4005a5a1684f0e40
diff --git a/java/com/android/incallui/CallerInfo.java b/java/com/android/incallui/CallerInfo.java
index e552d7c..cc1a60a 100644
--- a/java/com/android/incallui/CallerInfo.java
+++ b/java/com/android/incallui/CallerInfo.java
@@ -162,6 +162,8 @@
*/
public String callSubject;
+ public String countryIso;
+
private boolean mIsEmergency;
private boolean mIsVoiceMail;
@@ -522,7 +524,7 @@
*/
public void updateGeoDescription(Context context, String fallbackNumber) {
String number = TextUtils.isEmpty(phoneNumber) ? fallbackNumber : phoneNumber;
- geoDescription = PhoneNumberHelper.getGeoDescription(context, number);
+ geoDescription = PhoneNumberHelper.getGeoDescription(context, number, countryIso);
}
/** @return a string debug representation of this instance. */
diff --git a/java/com/android/incallui/CallerInfoAsyncQuery.java b/java/com/android/incallui/CallerInfoAsyncQuery.java
index 858d0f4..86b1b7f 100644
--- a/java/com/android/incallui/CallerInfoAsyncQuery.java
+++ b/java/com/android/incallui/CallerInfoAsyncQuery.java
@@ -162,6 +162,7 @@
cw.listener = listener;
cw.cookie = cookie;
cw.number = info.phoneNumber;
+ cw.countryIso = info.countryIso;
// check to see if these are recognized numbers, and use shortcuts if we can.
if (PhoneNumberUtils.isLocalEmergencyNumber(context, info.phoneNumber)) {
@@ -268,6 +269,7 @@
public Object cookie;
public int event;
public String number;
+ public String countryIso;
}
/* Directory lookup related code - END */
@@ -493,6 +495,7 @@
mCallerInfo = newCallerInfo;
Log.d(this, "#####async contact look up with numeric username" + mCallerInfo);
}
+ mCallerInfo.countryIso = cw.countryIso;
// Final step: look up the geocoded description.
if (ENABLE_UNKNOWN_NUMBER_GEO_DESCRIPTION) {
diff --git a/java/com/android/incallui/CallerInfoUtils.java b/java/com/android/incallui/CallerInfoUtils.java
index 8f23107..bf586f5 100644
--- a/java/com/android/incallui/CallerInfoUtils.java
+++ b/java/com/android/incallui/CallerInfoUtils.java
@@ -70,7 +70,7 @@
"CallerInfoUtils.getCallerInfoForCall",
"Actually starting CallerInfoAsyncQuery.startQuery()...");
- //noinspection MissingPermission
+ // noinspection MissingPermission
CallerInfoAsyncQuery.startQuery(QUERY_TOKEN, context, info, listener, cookie);
} else {
LogUtil.w(
@@ -93,6 +93,7 @@
info.namePresentation = call.getCnapNamePresentation();
info.callSubject = call.getCallSubject();
info.contactExists = false;
+ info.countryIso = PhoneNumberHelper.getCurrentCountryIso(context, call.getAccountHandle());
String number = call.getNumber();
if (!TextUtils.isEmpty(number)) {
diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java
index 7bac6d3..39c4c2f 100644
--- a/java/com/android/incallui/ContactInfoCache.java
+++ b/java/com/android/incallui/ContactInfoCache.java
@@ -211,7 +211,7 @@
// No name, but we do have a valid CNAP name, so use that.
displayName = info.cnapName;
info.name = info.cnapName;
- displayNumber = PhoneNumberHelper.formatNumber(number, context);
+ displayNumber = PhoneNumberHelper.formatNumber(number, info.countryIso);
Log.d(
TAG,
" ==> cnapName available: displayName '"
@@ -224,7 +224,7 @@
// case when an incoming call doesn't match any contact,
// or if you manually dial an outgoing number using the
// dialpad.
- displayNumber = PhoneNumberHelper.formatNumber(number, context);
+ displayNumber = PhoneNumberHelper.formatNumber(number, info.countryIso);
Log.d(
TAG,
@@ -249,7 +249,7 @@
// later determine whether to use the name or nameAlternative when presenting
displayName = info.name;
cce.nameAlternative = info.nameAlternative;
- displayNumber = PhoneNumberHelper.formatNumber(number, context);
+ displayNumber = PhoneNumberHelper.formatNumber(number, info.countryIso);
label = info.phoneLabel;
Log.d(
TAG,