diff options
author | Deepak Kundra <deepakkundra@gmail.com> | 2016-04-20 19:55:26 -0700 |
---|---|---|
committer | Deepak Kundra <deepakkundra@gmail.com> | 2016-04-22 17:09:37 -0700 |
commit | 3e3f77dddbeaab25a7c44e76eac26575e7f52350 (patch) | |
tree | b5875006089b74b5452407b99a468ce46a090dfe /telephony | |
parent | 76e688baec286efe5744081b50420369f3e62394 (diff) | |
download | frameworks_base-3e3f77dddbeaab25a7c44e76eac26575e7f52350.zip frameworks_base-3e3f77dddbeaab25a7c44e76eac26575e7f52350.tar.gz frameworks_base-3e3f77dddbeaab25a7c44e76eac26575e7f52350.tar.bz2 |
Support for new properties to identify country based ecc #s added by RIL
If the device is in a country where the ecclist list has been
updated with the current country's ECC#s. For example if device
is in INDIA and we are checking for (XYZ, am, 101, XYZ) it will
return true since 101 will be found in ecclist but 101 is not
valid ECC# for Armenia(am). There could be a case where this
logic errors. For example 101 is valid ECC for INDIA and PAK
and we are currently in INDIA and CTS passes (XYZ, pk, 101,
XYZ). We should return true/valid ECC# but current logic will
return false. This scenario fails even today, so there is no
regression.
Issue-id:CYNGNOS-2412
Change-Id: I6e19aed8a84bd57244a40e7f1e06d4625d26ec77
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 5ee1fb2..a70233f 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -1935,11 +1935,13 @@ public class PhoneNumberUtils // It is not possible to append additional digits to an emergency number to dial // the number in Brazil - it won't connect. if (useExactMatch || "BR".equalsIgnoreCase(defaultCountryIso)) { - if (number.equals(emergencyNum)) { + if (number.equals(emergencyNum) && + isEmergencyNumberForCurrentIso(number, defaultCountryIso, slotId)) { return true; } } else { - if (number.startsWith(emergencyNum)) { + if (number.startsWith(emergencyNum) && + isEmergencyNumberForCurrentIso(number, defaultCountryIso, slotId)) { return true; } } @@ -1982,6 +1984,57 @@ public class PhoneNumberUtils } /** + * When checking for ECC numbers the country (defaultCountryIso) passed in is not taken into + * consideration by the function isEmergencyNumberInternal(subId, number, defaultCountryIso, + * useExactMatchecclist) this causes the function to return TRUE even in the case when the + * number is not emergency for defaultCountryIso. + */ + private static boolean isEmergencyNumberForCurrentIso(String number, + String country, + int slotId) { + Rlog.w(LOG_TAG, "isEmergencyNumberForCurrentIso: number =" + number + " iso=" + country); + + String mccEccIso = ""; + String mccEccIsoProp = (slotId == 0) ? "ril.mcc.ecc.iso" : ("ril.mcc.ecc.iso" + slotId); + mccEccIso = SystemProperties.get(mccEccIsoProp, ""); + + if (TextUtils.isEmpty(mccEccIso) || TextUtils.isEmpty(country) || slotId < 0 || + isEmergencyIsoMatchCountryIso(mccEccIso, country)) { + Rlog.w(LOG_TAG, "MCC/ISO is empty or matches region for ECC#'s set via RIL db"); + return true; + } + + String mccEccList = ""; + String mccEccListProp = (slotId == 0) ? "ril.mcc.ecclist" : ("ril.mcc.ecclist" + slotId); + mccEccList = SystemProperties.get(mccEccListProp, ""); + + if (!TextUtils.isEmpty(mccEccList)) { + for (String emergencyNum : mccEccList.split(",")) { + if (number.equals(emergencyNum)) { + Rlog.w(LOG_TAG, "Number " + number + " matches with " + mccEccListProp); + return false; + } + } + } + + return true; + } + + /** + * Checks if the two strings passed are equal ignoring the case + */ + private static boolean isEmergencyIsoMatchCountryIso(String iso, String country) { + Rlog.w(LOG_TAG, "isEmergencyIsoMatchCountryIso: iso=" + iso + " country=" + country); + + if(iso.equalsIgnoreCase(country)) { + return true; + } else { + return false; + } + + } + + /** * Checks if a given number is an emergency number for the country that the user is in. * * @param number the number to look up. |