|
|
|
@ -619,6 +619,7 @@ class PhoneNumberRegExpsAndMappings { |
|
|
|
} |
|
|
|
|
|
|
|
mobile_token_mappings_.insert(std::make_pair(54, '9')); |
|
|
|
countries_without_national_prefix_with_area_codes_.insert(52); // Mexico
|
|
|
|
geo_mobile_countries_without_mobile_area_codes_.insert(86); // China
|
|
|
|
geo_mobile_countries_.insert(52); // Mexico
|
|
|
|
geo_mobile_countries_.insert(54); // Argentina
|
|
|
|
@ -696,6 +697,10 @@ class PhoneNumberRegExpsAndMappings { |
|
|
|
// to be an area code.
|
|
|
|
std::set<int> geo_mobile_countries_without_mobile_area_codes_; |
|
|
|
|
|
|
|
// Set of country codes that doesn't have national prefix, but it has area
|
|
|
|
// codes.
|
|
|
|
std::set<int> 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.
|
|
|
|
@ -795,6 +800,7 @@ class PhoneNumberRegExpsAndMappings { |
|
|
|
alpha_phone_mappings_(), |
|
|
|
all_plus_number_grouping_symbols_(), |
|
|
|
mobile_token_mappings_(), |
|
|
|
countries_without_national_prefix_with_area_codes_(), |
|
|
|
geo_mobile_countries_without_mobile_area_codes_(), |
|
|
|
geo_mobile_countries_(), |
|
|
|
single_international_prefix_(regexp_factory_->CreateRegExp( |
|
|
|
@ -2676,15 +2682,22 @@ int PhoneNumberUtil::GetLengthOfGeographicalAreaCode( |
|
|
|
if (!metadata) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
PhoneNumberType type = GetNumberType(number); |
|
|
|
int country_calling_code = number.country_code(); |
|
|
|
|
|
|
|
// 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->has_national_prefix() && !number.italian_leading_zero()) { |
|
|
|
// Note:this is our general assumption, but there are exceptions which are
|
|
|
|
// tracked in COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES.
|
|
|
|
if (!metadata->has_national_prefix() && !number.italian_leading_zero() && |
|
|
|
reg_exps_->countries_without_national_prefix_with_area_codes_.find( |
|
|
|
country_calling_code) == |
|
|
|
reg_exps_->countries_without_national_prefix_with_area_codes_.end()) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
PhoneNumberType type = GetNumberType(number); |
|
|
|
int country_calling_code = number.country_code(); |
|
|
|
if (type == PhoneNumberUtil::MOBILE && |
|
|
|
reg_exps_->geo_mobile_countries_without_mobile_area_codes_.find( |
|
|
|
country_calling_code) != |
|
|
|
|