summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tyler Gunn <tgunn@google.com> 2017-02-27 02:54:49 +0000
committer android-build-merger <android-build-merger@google.com> 2017-02-27 02:54:49 +0000
commit8ac499fbe68c969fa929e9428cae4dc8d49d75f0 (patch)
tree4912b7f72922fc7d67bf45481523fee7b6bbc308
parent82c46d11f6a84ac34c0fb82ea6845db33e63a439 (diff)
parent050e5ddb4feaa399cce2e2256dadcd12851e2e76 (diff)
Merge "Format Japanese numbers using national format when in Japan."
am: 050e5ddb4f Change-Id: I996a79c2b3158e1fd6999330e0b0b21f8e4c8b4b
-rw-r--r--telephony/java/android/telephony/PhoneNumberUtils.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index 6f51c6e3e461..cc21b5ec116d 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -1140,6 +1140,8 @@ public class PhoneNumberUtils
private static final String KOREA_ISO_COUNTRY_CODE = "KR";
+ private static final String JAPAN_ISO_COUNTRY_CODE = "JP";
+
/**
* Breaks the given number down and formats it according to the rules
* for the country the number is from.
@@ -1460,15 +1462,25 @@ public class PhoneNumberUtils
String result = null;
try {
PhoneNumber pn = util.parseAndKeepRawInput(phoneNumber, defaultCountryIso);
- /**
- * Need to reformat any local Korean phone numbers (when the user is in Korea) with
- * country code to corresponding national format which would replace the leading
- * +82 with 0.
- */
- if (KOREA_ISO_COUNTRY_CODE.equals(defaultCountryIso) &&
+
+ if (KOREA_ISO_COUNTRY_CODE.equalsIgnoreCase(defaultCountryIso) &&
(pn.getCountryCode() == util.getCountryCodeForRegion(KOREA_ISO_COUNTRY_CODE)) &&
(pn.getCountryCodeSource() ==
PhoneNumber.CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN)) {
+ /**
+ * Need to reformat any local Korean phone numbers (when the user is in Korea) with
+ * country code to corresponding national format which would replace the leading
+ * +82 with 0.
+ */
+ result = util.format(pn, PhoneNumberUtil.PhoneNumberFormat.NATIONAL);
+ } else if (JAPAN_ISO_COUNTRY_CODE.equalsIgnoreCase(defaultCountryIso) &&
+ pn.getCountryCode() == util.getCountryCodeForRegion(JAPAN_ISO_COUNTRY_CODE) &&
+ (pn.getCountryCodeSource() ==
+ PhoneNumber.CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN)) {
+ /**
+ * Need to reformat Japanese phone numbers (when user is in Japan) with the national
+ * dialing format.
+ */
result = util.format(pn, PhoneNumberUtil.PhoneNumberFormat.NATIONAL);
} else {
result = util.formatInOriginalFormat(pn, defaultCountryIso);