diff options
| author | 2010-07-16 13:42:31 -0700 | |
|---|---|---|
| committer | 2010-07-16 13:42:31 -0700 | |
| commit | 4248d5887bf9d7d65b649a9ca0c7ba623135eed5 (patch) | |
| tree | 5b9561df4fd444f036e83687a17ac1c2fab7333b | |
| parent | f7adbe10c23ca86e70a6e3a8b1a90ebe23142d29 (diff) | |
| parent | adff0ad3cdae6c9bf043ab40fb0f40a54d5151ac (diff) | |
merge from open-source master
Change-Id: I87dc9cac9d5bf8543de8273e8b0bf72ec22e2d5f
| -rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index f2212fb58448..1d3ad81b8490 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -55,6 +55,12 @@ public class PhoneNumberUtils public static final char WILD = 'N'; /* + * Calling Line Identification Restriction (CLIR) + */ + private static final String CLIR_ON = "*31#+"; + private static final String CLIR_OFF = "#31#+"; + + /* * TOA = TON + NPI * See TS 24.008 section 10.5.4.7 for details. * These are the only really useful TOA values @@ -179,8 +185,6 @@ public class PhoneNumberUtils * Please note that the GSM wild character is allowed in the result. * This must be resolved before dialing. * - * Allows + only in the first position in the result string. - * * Returns null if phoneNumber == null */ public static String @@ -203,6 +207,11 @@ public class PhoneNumberUtils } } + int pos = addPlusChar(phoneNumber); + if (pos >= 0 && ret.length() > pos) { + ret.insert(pos, '+'); + } + return ret.toString(); } @@ -304,6 +313,28 @@ public class PhoneNumberUtils } } + /** GSM codes + * Finds if a GSM code includes the international prefix (+). + * + * @param number the number to dial. + * + * @return the position where the + char will be inserted, -1 if the GSM code was not found. + */ + private static int + addPlusChar(String number) { + int pos = -1; + + if (number.startsWith(CLIR_OFF)) { + pos = CLIR_OFF.length() - 1; + } + + if (number.startsWith(CLIR_ON)) { + pos = CLIR_ON.length() - 1; + } + + return pos; + } + /** * Extracts the post-dial sequence of DTMF control digits, pauses, and * waits. Strips separators. This string may be empty, but will not be null |