diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-06-24 15:42:43 -0700 |
---|---|---|
committer | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-06-27 15:20:46 -0700 |
commit | 3746f2d91425e24b23ddf34f2b9afef3f3efc3e2 (patch) | |
tree | eb95e9f894bc409229986da734db0df178e9cc6e | |
parent | da1fa1e42fc7fb07d532f464b45d266801c20e73 (diff) | |
download | frameworks_base-3746f2d91425e24b23ddf34f2b9afef3f3efc3e2.zip frameworks_base-3746f2d91425e24b23ddf34f2b9afef3f3efc3e2.tar.gz frameworks_base-3746f2d91425e24b23ddf34f2b9afef3f3efc3e2.tar.bz2 |
Use upper case country codes in Country.java
Previously external/libphonenumber accepted lower case
country codes (e.g. "us") but now it doesn't for performance reason.
Actually ISO 3166-1 doesn't allow lower cases, so we should not rely
on them.
Need to fix unit tests for PhoneNumberUtils, as it implicitly
relies on the previous behavior.
See also I3a3e6db84ed0d24290b1be19651fa9a82de4cc39
Bug: 4941319
Change-Id: If16f6531f274a0faf5e28724854409ca9b00a669
-rwxr-xr-x | location/java/android/location/Country.java | 4 | ||||
-rw-r--r-- | telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java | 13 |
2 files changed, 10 insertions, 7 deletions
diff --git a/location/java/android/location/Country.java b/location/java/android/location/Country.java index 3c05403..939bd4a 100755 --- a/location/java/android/location/Country.java +++ b/location/java/android/location/Country.java @@ -19,6 +19,8 @@ package android.location; import android.os.Parcel; import android.os.Parcelable; +import java.util.Locale; + /** * This class wraps the country information. * @@ -74,7 +76,7 @@ public class Country implements Parcelable { || source > COUNTRY_SOURCE_LOCALE) { throw new IllegalArgumentException(); } - mCountryIso = countryIso.toLowerCase(); + mCountryIso = countryIso.toUpperCase(Locale.US); mSource = source; } diff --git a/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java b/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java index c4a6f53..6e9d0f9d 100644 --- a/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java +++ b/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java @@ -502,16 +502,17 @@ public class PhoneNumberUtilsTest extends AndroidTestCase { @SmallTest public void testFormatNumberToE164() { - assertEquals("+16502910000", PhoneNumberUtils.formatNumberToE164("650 2910000", "us")); - assertNull(PhoneNumberUtils.formatNumberToE164("1234567", "us")); - assertEquals("+18004664114", PhoneNumberUtils.formatNumberToE164("800-GOOG-114", "us")); + // Note: ISO 3166-1 only allows upper case country codes. + assertEquals("+16502910000", PhoneNumberUtils.formatNumberToE164("650 2910000", "US")); + assertNull(PhoneNumberUtils.formatNumberToE164("1234567", "US")); + assertEquals("+18004664114", PhoneNumberUtils.formatNumberToE164("800-GOOG-114", "US")); } @SmallTest public void testFormatNumber() { - assertEquals("(650) 291-0000", PhoneNumberUtils.formatNumber("650 2910000", "us")); - assertEquals("123-4567", PhoneNumberUtils.formatNumber("1234567", "us")); - assertEquals("(800) 466-4114", PhoneNumberUtils.formatNumber("800-GOOG-114", "us")); + assertEquals("(650) 291-0000", PhoneNumberUtils.formatNumber("650 2910000", "US")); + assertEquals("123-4567", PhoneNumberUtils.formatNumber("1234567", "US")); + assertEquals("(800) 466-4114", PhoneNumberUtils.formatNumber("800-GOOG-114", "US")); } |