diff options
author | Tammo Spalink <tammo@google.com> | 2009-10-19 14:10:47 +0800 |
---|---|---|
committer | Tammo Spalink <tammo@google.com> | 2009-10-21 10:30:58 +0800 |
commit | 9e534153264138cfee383c626db92b934fafc1af (patch) | |
tree | bad43dee9a316223b1c468f6e057fd6c470a51ac /telephony | |
parent | eab82c3c8c9dd88ff7267c154b415558d8e5c206 (diff) | |
download | frameworks_base-9e534153264138cfee383c626db92b934fafc1af.zip frameworks_base-9e534153264138cfee383c626db92b934fafc1af.tar.gz frameworks_base-9e534153264138cfee383c626db92b934fafc1af.tar.bz2 |
Let PLUS occur once anywhere in dial-str network portion.
Create a new extractNetworkPortion() function, since the old one is
public, that does effectively the same thing but is more flexible as
just mentioned.
Addresses issue:
http://buganizer/issue?id=2013998
Change-Id: Ie5df08ef9c871881e8728a44abf0385908000823
Diffstat (limited to 'telephony')
6 files changed, 45 insertions, 10 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 1aa1c76..a0a1b14 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -207,6 +207,42 @@ public class PhoneNumberUtils } /** + * Extracts the network address portion and canonicalize. + * + * This function is equivalent to extractNetworkPortion(), except + * for allowing the PLUS character to occur at arbitrary positions + * in the address portion, not just the first position. + * + * @hide + */ + public static String extractNetworkPortionAlt(String phoneNumber) { + if (phoneNumber == null) { + return null; + } + + int len = phoneNumber.length(); + StringBuilder ret = new StringBuilder(len); + boolean haveSeenPlus = false; + + for (int i = 0; i < len; i++) { + char c = phoneNumber.charAt(i); + if (c == '+') { + if (haveSeenPlus) { + continue; + } + haveSeenPlus = true; + } + if (isDialable(c)) { + ret.append(c); + } else if (isStartsPostDial (c)) { + break; + } + } + + return ret.toString(); + } + + /** * Strips separators from a phone number string. * @param phoneNumber phone number to strip. * @return phone string stripped of separators. @@ -590,7 +626,7 @@ public class PhoneNumberUtils */ public static String toCallerIDMinMatch(String phoneNumber) { - String np = extractNetworkPortion(phoneNumber); + String np = extractNetworkPortionAlt(phoneNumber); return internalGetStrippedReversed(np, MIN_MATCH); } @@ -603,7 +639,7 @@ public class PhoneNumberUtils */ public static String getStrippedReversed(String phoneNumber) { - String np = extractNetworkPortion(phoneNumber); + String np = extractNetworkPortionAlt(phoneNumber); if (np == null) return null; @@ -1247,7 +1283,7 @@ public class PhoneNumberUtils // Strip the separators from the number before comparing it // to the list. - number = extractNetworkPortion(number); + number = extractNetworkPortionAlt(number); // retrieve the list of emergency numbers String numbers = SystemProperties.get("ro.ril.ecclist"); @@ -1290,7 +1326,7 @@ public class PhoneNumberUtils // Strip the separators from the number before comparing it // to the list. - number = extractNetworkPortion(number); + number = extractNetworkPortionAlt(number); // compare tolerates null so we need to make sure that we // don't return true when both are null. diff --git a/telephony/java/com/android/internal/telephony/DriverCall.java b/telephony/java/com/android/internal/telephony/DriverCall.java index 0d9a60f..66f6b9c 100644 --- a/telephony/java/com/android/internal/telephony/DriverCall.java +++ b/telephony/java/com/android/internal/telephony/DriverCall.java @@ -73,8 +73,7 @@ public class DriverCall implements Comparable { if (p.hasMore()) { // Some lame implementations return strings // like "NOT AVAILABLE" in the CLCC line - ret.number = PhoneNumberUtils.extractNetworkPortion( - p.nextString()); + ret.number = PhoneNumberUtils.extractNetworkPortionAlt(p.nextString()); if (ret.number.length() == 0) { ret.number = null; diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java index 22fbe8b..5c537de 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java +++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java @@ -1317,7 +1317,7 @@ public class CDMAPhone extends PhoneBase { @Override public boolean isOtaSpNumber(String dialStr){ boolean isOtaSpNum = false; - String dialableStr = PhoneNumberUtils.extractNetworkPortion(dialStr); + String dialableStr = PhoneNumberUtils.extractNetworkPortionAlt(dialStr); if (dialableStr != null) { isOtaSpNum = isIs683OtaSpDialStr(dialableStr); if (isOtaSpNum == false) { diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaConnection.java b/telephony/java/com/android/internal/telephony/cdma/CdmaConnection.java index f637d33..08946d2 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaConnection.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaConnection.java @@ -154,7 +154,7 @@ public class CdmaConnection extends Connection { dialString = formatDialString(dialString); Log.d(LOG_TAG, "[CDMAConn] CdmaConnection:formated dialString=" + dialString); - this.address = PhoneNumberUtils.extractNetworkPortion(dialString); + this.address = PhoneNumberUtils.extractNetworkPortionAlt(dialString); this.postDialString = PhoneNumberUtils.extractPostDialPortion(dialString); index = -1; diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java index 5614c12..56499a8 100755 --- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java +++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java @@ -729,7 +729,7 @@ public class GSMPhone extends PhoneBase { } // Only look at the Network portion for mmi - String networkPortion = PhoneNumberUtils.extractNetworkPortion(newDialString); + String networkPortion = PhoneNumberUtils.extractNetworkPortionAlt(newDialString); GsmMmiCode mmi = GsmMmiCode.newFromDialString(networkPortion, this); if (LOCAL_DEBUG) Log.d(LOG_TAG, "dialing w/ mmi '" + mmi + "'..."); diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java b/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java index 445be39..4788a01 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java @@ -144,7 +144,7 @@ public class GsmConnection extends Connection { this.dialString = dialString; - this.address = PhoneNumberUtils.extractNetworkPortion(dialString); + this.address = PhoneNumberUtils.extractNetworkPortionAlt(dialString); this.postDialString = PhoneNumberUtils.extractPostDialPortion(dialString); index = -1; |