From f9ae7fca5b1a944c7d9d2f0536ab1912040d31a6 Mon Sep 17 00:00:00 2001 From: Michael Rozumyanskiy Date: Sun, 13 Oct 2024 23:49:09 +0300 Subject: [PATCH 1/2] Bump version to 8.13.40 --- README.md | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5b8af2ff..24f36a80 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ repositories { } dependencies { - implementation 'io.michaelrocks:libphonenumber-android:8.13.39' + implementation 'io.michaelrocks:libphonenumber-android:8.13.40' } ``` @@ -63,5 +63,5 @@ License limitations under the License. [1]: https://github.com/googlei18n/libphonenumber - [2]: http://www.methodscount.com/?lib=com.googlecode.libphonenumber%3Alibphonenumber%3A8.13.39 + [2]: http://www.methodscount.com/?lib=com.googlecode.libphonenumber%3Alibphonenumber%3A8.13.40 [3]: http://blog.nimbledroid.com/2016/04/06/slow-ClassLoader.getResourceAsStream.html diff --git a/build.gradle b/build.gradle index 4c415742..b3a99b9a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { group = 'io.michaelrocks' - version = '8.13.39' + version = '8.13.40' ext.projectCompileSdkVersion = 35 ext.projectBuildToolsVersion = '35.0.0' From de70e8c5f5b394be391a718cefde5e3bb2ac838c Mon Sep 17 00:00:00 2001 From: Michael Rozumyanskiy Date: Sun, 13 Oct 2024 23:49:10 +0300 Subject: [PATCH 2/2] Merge code and metadata changes from 8.13.40 --- .../android/data/PhoneNumberMetadataProto_FI | Bin 1481 -> 1495 bytes .../android/data/PhoneNumberMetadataProto_GE | Bin 1110 -> 1117 bytes .../android/data/PhoneNumberMetadataProto_GY | Bin 540 -> 533 bytes .../android/data/PhoneNumberMetadataProto_HK | Bin 1482 -> 1486 bytes .../android/data/PhoneNumberMetadataProto_IL | Bin 1192 -> 1193 bytes .../android/data/PhoneNumberMetadataProto_MU | Bin 721 -> 721 bytes .../android/data/PhoneNumberMetadataProto_MX | Bin 1460 -> 1460 bytes .../android/data/PhoneNumberMetadataProto_TD | Bin 386 -> 387 bytes .../android/data/ShortNumberMetadataProto_FI | Bin 281 -> 318 bytes .../android/PhoneNumberUtil.java | 18 +++++++++++++++--- .../android/PhoneNumberUtilTest.java | 3 +++ .../android/data/PhoneNumberMetadataProto_FI | Bin 1481 -> 1495 bytes .../android/data/PhoneNumberMetadataProto_GE | Bin 1110 -> 1117 bytes .../android/data/PhoneNumberMetadataProto_GY | Bin 540 -> 533 bytes .../android/data/PhoneNumberMetadataProto_HK | Bin 1482 -> 1486 bytes .../android/data/PhoneNumberMetadataProto_IL | Bin 1192 -> 1193 bytes .../android/data/PhoneNumberMetadataProto_MU | Bin 721 -> 721 bytes .../android/data/PhoneNumberMetadataProto_MX | Bin 1460 -> 1460 bytes .../android/data/PhoneNumberMetadataProto_TD | Bin 386 -> 387 bytes .../android/data/ShortNumberMetadataProto_FI | Bin 281 -> 318 bytes 20 files changed, 18 insertions(+), 3 deletions(-) diff --git a/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_FI b/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_FI index 1497e86869fb85ddfeaa35d2a9362c9e20423561..2ed02254a523a1ea527f51c579e3e8f733bf3f51 100644 GIT binary patch delta 77 zcmX@feVuzkgS3ZXw6UqKd2Fsb3;=VD5sv@> diff --git a/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GE b/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GE index 27f9e4f11f6e4d77e0fb14d40129341f8248f6a1..894199b9114a8240378a9fea399a13e5e2763586 100644 GIT binary patch delta 37 tcmcb{ahGGlCdR81H@C4F8ATfy#csA>JjKLW9>l=Fz{tQ7J(-)u8vp`&3jqKC delta 38 ucmcc1agAfbCdP9UH@9teU_8mh%fP_E$iNa^?rmxw%P{#4v+iVP7AXJ?LksBu diff --git a/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GY b/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GY index 4aefd41e81480a15794f244e3a5609d928ebb426..2c822fa5a700d01db017c76b61e144ea037226a0 100644 GIT binary patch delta 62 zcmbQkGL?mM&07Z6Dh387o{5~BH4HWEtxOFKYRqC%Vp3|%fxKt~Lu1oeAjc@$K-VI+ O#so+inQVM*$Or%$0uiJD delta 69 zcmbQrGKYn8&07Z6Dh387;fb7^^({2)txOFKYRqC%Vp3|%fxKt~L*rN=+bG&V*T_`Y UBDTf^#IlU7F^x9d_{5MA0GvbW#q#~96|YrI*C=`|x~6$1m~0n1p;n$3JHdl&&>><*Ry delta 37 tcmX@deTsX+KgN)W|MyQm$QaFNv{{bnH6y2GtY%FW0|Vop%|a}D7y%`<4TJyy diff --git a/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_IL b/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_IL index 43c43462afc61fee0d2233d994d4a5bb6b2a2e8f..e175ede33416ab916be5bc67da07b354c5f2fe6f 100644 GIT binary patch delta 41 vcmZ3%xsr1O2a`yOxrV)!u?3JYh)Jn2jW*CVGTkiA^p=sie4gQCZkD+K>C_8= delta 40 ucmZ382a|BJxrV)!u?3JYh)Jn2jW*CV+APELmXX=8eC}i(mbn1m0Sih1 diff --git a/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MU b/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MU index 5358c7f088515029191dd82430fa380a0d4dfe26..d650f761ca53bacdc6b603dfc790527d45c61d68 100644 GIT binary patch delta 14 Vcmcb}dXaU5IwPaWW(~%bi~uCN1V8`) delta 14 Vcmcb}dXaU5IwPa;W(~%bi~uCH1U~=( diff --git a/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MX b/library/src/main/assets/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MX index 7813a32bf29666bde399b2371d49d81f626f9cf4..14ecf959ac10357873fb68a030adfa79daa02dd6 100644 GIT binary patch delta 25 gcmdnOy@h*&3?rk#W?9BFKx(oqZeo^P^Ok|Nih+T#k^x9CGBSv2*jpJH)kK?3lnUoJi#E_Tv#^Y 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 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 @@ -132,6 +135,11 @@ public class PhoneNumberUtil { GEO_MOBILE_COUNTRIES_WITHOUT_MOBILE_AREA_CODES = Collections.unmodifiableSet(geoMobileCountriesWithoutMobileAreaCodes); + HashSet countriesWithoutNationalPrefixWithAreaCodes = new HashSet<>(); + countriesWithoutNationalPrefixWithAreaCodes.add(52); // Mexico + COUNTRIES_WITHOUT_NATIONAL_PREFIX_WITH_AREA_CODES = + Collections.unmodifiableSet(countriesWithoutNationalPrefixWithAreaCodes); + HashSet geoMobileCountries = new HashSet<>(); geoMobileCountries.add(52); // Mexico geoMobileCountries.add(54); // Argentina @@ -923,14 +931,18 @@ public int getLengthOfGeographicalAreaCode(PhoneNumber number) { 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/library/src/test/java/io/michaelrocks/libphonenumber/android/PhoneNumberUtilTest.java b/library/src/test/java/io/michaelrocks/libphonenumber/android/PhoneNumberUtilTest.java index 441da2e3..24cac36b 100644 --- a/library/src/test/java/io/michaelrocks/libphonenumber/android/PhoneNumberUtilTest.java +++ b/library/src/test/java/io/michaelrocks/libphonenumber/android/PhoneNumberUtilTest.java @@ -311,6 +311,9 @@ public void testGetLengthOfGeographicalAreaCode() { // Italian numbers - there is no national prefix, but it still has an area code. assertEquals(2, phoneUtil.getLengthOfGeographicalAreaCode(IT_NUMBER)); + // Mexico numbers - there is no national prefix, but it still has an area code. + assertEquals(2, phoneUtil.getLengthOfGeographicalAreaCode(MX_NUMBER1)); + // Google Singapore. Singapore has no area code and no national prefix. assertEquals(0, phoneUtil.getLengthOfGeographicalAreaCode(SG_NUMBER)); diff --git a/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_FI b/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_FI index 1497e86869fb85ddfeaa35d2a9362c9e20423561..2ed02254a523a1ea527f51c579e3e8f733bf3f51 100644 GIT binary patch delta 77 zcmX@feVuzkgS3ZXw6UqKd2Fsb3;=VD5sv@> diff --git a/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GE b/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GE index 27f9e4f11f6e4d77e0fb14d40129341f8248f6a1..894199b9114a8240378a9fea399a13e5e2763586 100644 GIT binary patch delta 37 tcmcb{ahGGlCdR81H@C4F8ATfy#csA>JjKLW9>l=Fz{tQ7J(-)u8vp`&3jqKC delta 38 ucmcc1agAfbCdP9UH@9teU_8mh%fP_E$iNa^?rmxw%P{#4v+iVP7AXJ?LksBu diff --git a/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GY b/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_GY index 4aefd41e81480a15794f244e3a5609d928ebb426..2c822fa5a700d01db017c76b61e144ea037226a0 100644 GIT binary patch delta 62 zcmbQkGL?mM&07Z6Dh387o{5~BH4HWEtxOFKYRqC%Vp3|%fxKt~Lu1oeAjc@$K-VI+ O#so+inQVM*$Or%$0uiJD delta 69 zcmbQrGKYn8&07Z6Dh387;fb7^^({2)txOFKYRqC%Vp3|%fxKt~L*rN=+bG&V*T_`Y UBDTf^#IlU7F^x9d_{5MA0GvbW#q#~96|YrI*C=`|x~6$1m~0n1p;n$3JHdl&&>><*Ry delta 37 tcmX@deTsX+KgN)W|MyQm$QaFNv{{bnH6y2GtY%FW0|Vop%|a}D7y%`<4TJyy diff --git a/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_IL b/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_IL index 43c43462afc61fee0d2233d994d4a5bb6b2a2e8f..e175ede33416ab916be5bc67da07b354c5f2fe6f 100644 GIT binary patch delta 41 vcmZ3%xsr1O2a`yOxrV)!u?3JYh)Jn2jW*CVGTkiA^p=sie4gQCZkD+K>C_8= delta 40 ucmZ382a|BJxrV)!u?3JYh)Jn2jW*CV+APELmXX=8eC}i(mbn1m0Sih1 diff --git a/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MU b/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MU index 5358c7f088515029191dd82430fa380a0d4dfe26..d650f761ca53bacdc6b603dfc790527d45c61d68 100644 GIT binary patch delta 14 Vcmcb}dXaU5IwPaWW(~%bi~uCN1V8`) delta 14 Vcmcb}dXaU5IwPa;W(~%bi~uCH1U~=( diff --git a/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MX b/library/src/test/resources/io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_MX index 7813a32bf29666bde399b2371d49d81f626f9cf4..14ecf959ac10357873fb68a030adfa79daa02dd6 100644 GIT binary patch delta 25 gcmdnOy@h*&3?rk#W?9BFKx(oqZeo^P^Ok|Nih+T#k^x9CGBSv2*jpJH)kK?3lnUoJi#E_Tv#^Y