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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user