diff options
author | Babis Triantafyllou <babis.triantafyllou.x@sonyericsson.com> | 2010-04-08 08:19:39 +0200 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonyericsson.com> | 2010-07-14 13:59:01 +0200 |
commit | adff0ad3cdae6c9bf043ab40fb0f40a54d5151ac (patch) | |
tree | 6800f8f6b87b6389dfb467a45b937a665cd1383e /telephony/java | |
parent | 25940667870e782c1d84ed7f6e4e87d92c14c6cb (diff) | |
download | frameworks_base-adff0ad3cdae6c9bf043ab40fb0f40a54d5151ac.zip frameworks_base-adff0ad3cdae6c9bf043ab40fb0f40a54d5151ac.tar.gz frameworks_base-adff0ad3cdae6c9bf043ab40fb0f40a54d5151ac.tar.bz2 |
Makes PhoneNumberUtils support international numbers after a CLIR command.
Makes PhoneNumberUtils.java support numbers in international
format (starting with ‘+’ character) after a CLIR command.
Previously a plus character would always be removed unless it
occupied the first position of the number string. In this case,
when the number is preceded by #31# (CLIR), the plus character
will be removed as well.
This is an error, prohibiting a type approval of the phone.
This change will detect the plus character after the CLIR command
and will insert it at the right position.
Change-Id: Ib220aee7b3eda30cde960db8c7470523dc5fd313
Diffstat (limited to 'telephony/java')
-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 f2212fb..1d3ad81 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 |