diff options
Diffstat (limited to 'libphonenumber/src')
10 files changed, 15 insertions, 3 deletions
diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index c49189fa..b6d72948 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -85,6 +85,9 @@ public class PhoneNumberUtil { // considered to be an area code. private static final Set<Integer> GEO_MOBILE_COUNTRIES_WITHOUT_MOBILE_AREA_CODES; + // Set of country codes that doesn't have national prefix, but it has area codes. + private static final Set<Integer> COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES; + // Set of country calling codes that have geographically assigned mobile numbers. This may not be // complete; we add calling codes case by case, as we find geographical mobile numbers or hear // from user reports. Note that countries like the US, where we can't distinguish between @@ -127,6 +130,11 @@ public class PhoneNumberUtil { GEO_MOBILE_COUNTRIES_WITHOUT_MOBILE_AREA_CODES = Collections.unmodifiableSet(geoMobileCountriesWithoutMobileAreaCodes); + HashSet<Integer> countriesWithoutNationalPrefixWithAreaCodes = new HashSet<>(); + countriesWithoutNationalPrefixWithAreaCodes.add(52); // Mexico + COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES = + Collections.unmodifiableSet(countriesWithoutNationalPrefixWithAreaCodes); + HashSet<Integer> geoMobileCountries = new HashSet<>(); geoMobileCountries.add(52); // Mexico geoMobileCountries.add(54); // Argentina @@ -893,14 +901,18 @@ public class PhoneNumberUtil { if (metadata == null) { return 0; } + + PhoneNumberType type = getNumberType(number); + int countryCallingCode = number.getCountryCode(); // If a country doesn't use a national prefix, and this number doesn't have an Italian leading // zero, we assume it is a closed dialling plan with no area codes. - if (!metadata.hasNationalPrefix() && !number.isItalianLeadingZero()) { + // Note:this is our general assumption, but there are exceptions which are tracked in + // COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES. + if (!metadata.hasNationalPrefix() && !number.isItalianLeadingZero() + && !COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES.contains(countryCallingCode)) { return 0; } - PhoneNumberType type = getNumberType(number); - int countryCallingCode = number.getCountryCode(); if (type == PhoneNumberType.MOBILE // Note this is a rough heuristic; it doesn't cover Indonesia well, for example, where area // codes are present for some mobile phones but not for others. We have no better way of diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FI b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FI Binary files differindex 1497e868..2ed02254 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FI +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FI diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE Binary files differindex 27f9e4f1..894199b9 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY Binary files differindex 4aefd41e..2c822fa5 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK Binary files differindex b6f41a7b..9db49ae4 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL Binary files differindex 43c43462..e175ede3 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MU b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MU Binary files differindex 5358c7f0..d650f761 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MU +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MU diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MX b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MX Binary files differindex 7813a32b..14ecf959 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MX +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MX diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TD b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TD Binary files differindex 79b852fa..3916ac2d 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TD +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TD diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_FI b/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_FI Binary files differindex 46b65272..ee615e75 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_FI +++ b/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_FI |