summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/compat
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2017-09-21 09:37:40 -0700
committerEric Erfanian <erfanian@google.com>2017-09-22 15:59:39 +0000
commit1420a22d5dc0d87f8634980b729a3511e42b6493 (patch)
treee82dd12010685713517e7b4737b999839880e843 /java/com/android/dialer/compat
parent3f4a31982fc815b1620671f16f7d45a8d2c07988 (diff)
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
Diffstat (limited to 'java/com/android/dialer/compat')
-rw-r--r--java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
index db1dd4ac4..ecd36d359 100644
--- a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
+++ b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
@@ -198,4 +198,34 @@ public class TelephonyManagerCompat {
context.sendBroadcast(intent);
}
}
+
+ /**
+ * Returns network country iso for given {@code PhoneAccountHandle} for O+ devices and country iso
+ * for default sim for pre-O devices.
+ */
+ public static String getNetworkCountryIsoForPhoneAccountHandle(
+ Context context, @Nullable PhoneAccountHandle phoneAccountHandle) {
+ return getTelephonyManagerForPhoneAccountHandle(context, phoneAccountHandle)
+ .getNetworkCountryIso();
+ }
+
+ /**
+ * Returns TelephonyManager for given {@code PhoneAccountHandle} for O+ devices and default {@code
+ * TelephonyManager} for pre-O devices.
+ */
+ public static TelephonyManager getTelephonyManagerForPhoneAccountHandle(
+ Context context, @Nullable PhoneAccountHandle phoneAccountHandle) {
+ TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
+ if (phoneAccountHandle == null) {
+ return telephonyManager;
+ }
+ if (VERSION.SDK_INT >= VERSION_CODES.O) {
+ TelephonyManager telephonyManagerForPhoneAccount =
+ telephonyManager.createForPhoneAccountHandle(phoneAccountHandle);
+ if (telephonyManagerForPhoneAccount != null) {
+ return telephonyManagerForPhoneAccount;
+ }
+ }
+ return telephonyManager;
+ }
}