Add Taiwan country code to be formatted for local calls to remove the
international prefix.
This change will also include a small refactor to store the country
codes in an array so other countries can be more easily added/removed.
Flag: com.android.internal.telephony.flags.national_country_code_formatting_for_local_calls
Bug: 293993310
Test: manual validity test, atest PhoneNumberUtilsTest
Change-Id: I0dfd133904103ff645a2d2ecb08c69a2cc9ede28
diff --git a/flags/calling.aconfig b/flags/calling.aconfig
index c1dc7e7..2809f79 100644
--- a/flags/calling.aconfig
+++ b/flags/calling.aconfig
@@ -21,6 +21,17 @@
# OWNER=stevestatia TARGET=24Q4
flag {
+ name: "national_country_code_formatting_for_local_calls"
+ namespace: "telephony"
+ description: "Make requests and bug fixes for formatting local calls based on country codes easier with a more scalable solution."
+ bug: "293993310"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+# OWNER=stevestatia TARGET=24Q4
+flag {
name: "remove_country_code_from_local_singapore_calls"
namespace: "telephony"
description: "Fix bug where the country code is being shown when merging in local Singapore numbers to conference calls."
diff --git a/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java b/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java
index bf9ced3..72d8197 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java
@@ -675,6 +675,43 @@
@SmallTest
@Test
+ public void testFormatTaiwanNational() {
+ // Disable feature flag.
+ mSetFlagsRule.disableFlags(Flags.FLAG_NATIONAL_COUNTRY_CODE_FORMATTING_FOR_LOCAL_CALLS);
+ assertEquals("+886 2 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "TW"));
+ assertEquals("+886 2 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "tw"));
+ assertEquals("+886 988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "TW"));
+ assertEquals("+886 988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "tw"));
+
+ // Enable feature flag.
+ mSetFlagsRule.enableFlags(Flags.FLAG_NATIONAL_COUNTRY_CODE_FORMATTING_FOR_LOCAL_CALLS);
+ assertEquals("02 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "TW"));
+ assertEquals("02 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "tw"));
+ assertEquals("0988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "TW"));
+ assertEquals("0988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "tw"));
+ mSetFlagsRule.disableFlags(Flags.FLAG_NATIONAL_COUNTRY_CODE_FORMATTING_FOR_LOCAL_CALLS);
+ }
+
+ @SmallTest
+ @Test
+ public void testFormatTaiwanInternational() {
+ // Disable feature flag.
+ mSetFlagsRule.disableFlags(Flags.FLAG_NATIONAL_COUNTRY_CODE_FORMATTING_FOR_LOCAL_CALLS);
+ assertEquals("+886 2 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "US"));
+ assertEquals("+886 2 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "us"));
+ assertEquals("+886 988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "US"));
+ assertEquals("+886 988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "us"));
+
+ mSetFlagsRule.enableFlags(Flags.FLAG_NATIONAL_COUNTRY_CODE_FORMATTING_FOR_LOCAL_CALLS);
+ assertEquals("+886 2 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "US"));
+ assertEquals("+886 2 8729 6000", PhoneNumberUtils.formatNumber("+886287296000", "us"));
+ assertEquals("+886 988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "US"));
+ assertEquals("+886 988 102 544", PhoneNumberUtils.formatNumber("+886988102544", "us"));
+ mSetFlagsRule.disableFlags(Flags.FLAG_NATIONAL_COUNTRY_CODE_FORMATTING_FOR_LOCAL_CALLS);
+ }
+
+ @SmallTest
+ @Test
public void testFormatNumber_LeadingStarAndHash() {
// Numbers with a leading '*' or '#' should be left unchanged.
assertEquals("*650 2910000", PhoneNumberUtils.formatNumber("*650 2910000", "US"));