summaryrefslogtreecommitdiff
path: root/java/src/com
diff options
context:
space:
mode:
authorShaopeng Jia <shaopengjia@google.com>2011-10-07 17:56:12 +0200
committerShaopeng Jia <shaopengjia@google.com>2011-10-07 17:56:12 +0200
commit1940212be2ff2ac5bf7d91eabbdb34e10d9b8e2e (patch)
tree75ab61e1cd3c108a9cc29f9e4811fa164da1b42e /java/src/com
parenta1d3a5ed3af9cee85acdad939042a851a629f18c (diff)
downloadlibphonenumber-1940212be2ff2ac5bf7d91eabbdb34e10d9b8e2e.tar.gz
Let formatInOriginalFormat to return raw_input for invalid phoneandroid-4.0.1_r1.2android-4.0.1_r1.1android-4.0.1_r1ics-factoryrom-2-release
numbers. Bug: 5412333 Change-Id: I029e6b19ca1e07098971b9622f9d0e83a3259b8c
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java b/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java
index 745fb7d1..230b8bf6 100644
--- a/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java
+++ b/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java
@@ -1216,7 +1216,8 @@ public class PhoneNumberUtil {
* Formats a phone number using the original phone number format that the number is parsed from.
* The original format is embedded in the country_code_source field of the PhoneNumber object
* passed in. If such information is missing, the number will be formatted into the NATIONAL
- * format by default.
+ * format by default. When the number is an invalid number, the method returns the raw input when
+ * it is available.
*
* @param number the phone number that needs to be formatted in its original number format
* @param regionCallingFrom the region whose IDD needs to be prefixed if the original number
@@ -1224,6 +1225,9 @@ public class PhoneNumberUtil {
* @return the formatted phone number in its original number format
*/
public String formatInOriginalFormat(PhoneNumber number, String regionCallingFrom) {
+ if (number.hasRawInput() && !isValidNumber(number)) {
+ return number.getRawInput();
+ }
if (!number.hasCountryCodeSource()) {
return format(number, PhoneNumberFormat.NATIONAL);
}