diff options
author | Michael W <baddaemon87@gmail.com> | 2019-11-17 17:02:38 +0100 |
---|---|---|
committer | Michael W <baddaemon87@gmail.com> | 2021-03-13 16:02:24 +0100 |
commit | 520e6e45a6f11c9f97bb4c4feba07712ae27264b (patch) | |
tree | bb8c885e57155c6a77894bb6e5e63e79efc93c21 | |
parent | 4457a818c338ec2d7bdaf2cf4b9499c043eac275 (diff) |
SensitivePhoneNumbers: Additionally check against the sim operator
* In order to also mark numbers as sensitive when calling to your home
country, check the sim's operator as well
* Also move the fallback mechanism out of the "else" in order to perform
as many checks as possible to not miss any case of hiding
Change-Id: I23b67145406793506be657df8b62f5d09b5a2a18
-rw-r--r-- | lib/src/java/org/lineageos/lib/phone/SensitivePhoneNumbers.java | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/src/java/org/lineageos/lib/phone/SensitivePhoneNumbers.java b/lib/src/java/org/lineageos/lib/phone/SensitivePhoneNumbers.java index b7827835..9bff6fbf 100644 --- a/lib/src/java/org/lineageos/lib/phone/SensitivePhoneNumbers.java +++ b/lib/src/java/org/lineageos/lib/phone/SensitivePhoneNumbers.java @@ -131,16 +131,30 @@ public class SensitivePhoneNumbers { return true; } } - } else { - // Fall back to check with the passed subId - TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class); - if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { - subId = SubscriptionManager.getDefaultSubscriptionId(); + } + + // Fall back to check with the passed subId + TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class); + if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { + subId = SubscriptionManager.getDefaultSubscriptionId(); + } + telephonyManager = telephonyManager.createForSubscriptionId(subId); + String networkUsed = telephonyManager.getNetworkOperator(); + if (!TextUtils.isEmpty(networkUsed)) { + String networkMCC = networkUsed.substring(0, 3); + if (isSensitiveNumber(nationalNumber, networkMCC)) { + return true; } - String networkUsed = telephonyManager.getNetworkOperator(subId); - if (!TextUtils.isEmpty(networkUsed)) { - String networkMCC = networkUsed.substring(0, 3); - return isSensitiveNumber(nationalNumber, networkMCC); + } + + // Also try the sim's operator + if (telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY) { + String simOperator = telephonyManager.getSimOperator(); + if (!TextUtils.isEmpty(simOperator)) { + String networkMCC = simOperator.substring(0, 3); + if (isSensitiveNumber(nationalNumber, networkMCC)) { + return true; + } } } |