am 8785c064: Merge change Ie5df08ef into eclair-mr2
Merge commit '8785c064fab3429c792ac160aeeb19e9926382f0' into eclair-mr2-plus-aosp * commit '8785c064fab3429c792ac160aeeb19e9926382f0': Let PLUS occur once anywhere in dial-str network portion.
This commit is contained in:
@@ -206,6 +206,42 @@ public class PhoneNumberUtils
|
|||||||
return ret.toString();
|
return ret.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Strips separators from a phone number string.
|
||||||
* @param phoneNumber phone number to strip.
|
* @param phoneNumber phone number to strip.
|
||||||
@@ -590,7 +626,7 @@ public class PhoneNumberUtils
|
|||||||
*/
|
*/
|
||||||
public static String
|
public static String
|
||||||
toCallerIDMinMatch(String phoneNumber) {
|
toCallerIDMinMatch(String phoneNumber) {
|
||||||
String np = extractNetworkPortion(phoneNumber);
|
String np = extractNetworkPortionAlt(phoneNumber);
|
||||||
return internalGetStrippedReversed(np, MIN_MATCH);
|
return internalGetStrippedReversed(np, MIN_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,7 +639,7 @@ public class PhoneNumberUtils
|
|||||||
*/
|
*/
|
||||||
public static String
|
public static String
|
||||||
getStrippedReversed(String phoneNumber) {
|
getStrippedReversed(String phoneNumber) {
|
||||||
String np = extractNetworkPortion(phoneNumber);
|
String np = extractNetworkPortionAlt(phoneNumber);
|
||||||
|
|
||||||
if (np == null) return null;
|
if (np == null) return null;
|
||||||
|
|
||||||
@@ -1247,7 +1283,7 @@ public class PhoneNumberUtils
|
|||||||
|
|
||||||
// Strip the separators from the number before comparing it
|
// Strip the separators from the number before comparing it
|
||||||
// to the list.
|
// to the list.
|
||||||
number = extractNetworkPortion(number);
|
number = extractNetworkPortionAlt(number);
|
||||||
|
|
||||||
// retrieve the list of emergency numbers
|
// retrieve the list of emergency numbers
|
||||||
String numbers = SystemProperties.get("ro.ril.ecclist");
|
String numbers = SystemProperties.get("ro.ril.ecclist");
|
||||||
@@ -1290,7 +1326,7 @@ public class PhoneNumberUtils
|
|||||||
|
|
||||||
// Strip the separators from the number before comparing it
|
// Strip the separators from the number before comparing it
|
||||||
// to the list.
|
// to the list.
|
||||||
number = extractNetworkPortion(number);
|
number = extractNetworkPortionAlt(number);
|
||||||
|
|
||||||
// compare tolerates null so we need to make sure that we
|
// compare tolerates null so we need to make sure that we
|
||||||
// don't return true when both are null.
|
// don't return true when both are null.
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ public class DriverCall implements Comparable {
|
|||||||
if (p.hasMore()) {
|
if (p.hasMore()) {
|
||||||
// Some lame implementations return strings
|
// Some lame implementations return strings
|
||||||
// like "NOT AVAILABLE" in the CLCC line
|
// like "NOT AVAILABLE" in the CLCC line
|
||||||
ret.number = PhoneNumberUtils.extractNetworkPortion(
|
ret.number = PhoneNumberUtils.extractNetworkPortionAlt(p.nextString());
|
||||||
p.nextString());
|
|
||||||
|
|
||||||
if (ret.number.length() == 0) {
|
if (ret.number.length() == 0) {
|
||||||
ret.number = null;
|
ret.number = null;
|
||||||
|
|||||||
@@ -1317,7 +1317,7 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isOtaSpNumber(String dialStr){
|
public boolean isOtaSpNumber(String dialStr){
|
||||||
boolean isOtaSpNum = false;
|
boolean isOtaSpNum = false;
|
||||||
String dialableStr = PhoneNumberUtils.extractNetworkPortion(dialStr);
|
String dialableStr = PhoneNumberUtils.extractNetworkPortionAlt(dialStr);
|
||||||
if (dialableStr != null) {
|
if (dialableStr != null) {
|
||||||
isOtaSpNum = isIs683OtaSpDialStr(dialableStr);
|
isOtaSpNum = isIs683OtaSpDialStr(dialableStr);
|
||||||
if (isOtaSpNum == false) {
|
if (isOtaSpNum == false) {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class CdmaConnection extends Connection {
|
|||||||
dialString = formatDialString(dialString);
|
dialString = formatDialString(dialString);
|
||||||
Log.d(LOG_TAG, "[CDMAConn] CdmaConnection:formated dialString=" + 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);
|
this.postDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
|
||||||
|
|
||||||
index = -1;
|
index = -1;
|
||||||
|
|||||||
@@ -729,7 +729,7 @@ public class GSMPhone extends PhoneBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only look at the Network portion for mmi
|
// Only look at the Network portion for mmi
|
||||||
String networkPortion = PhoneNumberUtils.extractNetworkPortion(newDialString);
|
String networkPortion = PhoneNumberUtils.extractNetworkPortionAlt(newDialString);
|
||||||
GsmMmiCode mmi = GsmMmiCode.newFromDialString(networkPortion, this);
|
GsmMmiCode mmi = GsmMmiCode.newFromDialString(networkPortion, this);
|
||||||
if (LOCAL_DEBUG) Log.d(LOG_TAG,
|
if (LOCAL_DEBUG) Log.d(LOG_TAG,
|
||||||
"dialing w/ mmi '" + mmi + "'...");
|
"dialing w/ mmi '" + mmi + "'...");
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class GsmConnection extends Connection {
|
|||||||
|
|
||||||
this.dialString = dialString;
|
this.dialString = dialString;
|
||||||
|
|
||||||
this.address = PhoneNumberUtils.extractNetworkPortion(dialString);
|
this.address = PhoneNumberUtils.extractNetworkPortionAlt(dialString);
|
||||||
this.postDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
|
this.postDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
|
||||||
|
|
||||||
index = -1;
|
index = -1;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import junit.framework.TestCase;
|
|||||||
public class PhoneNumberUtilsTest extends TestCase {
|
public class PhoneNumberUtilsTest extends TestCase {
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testA() throws Exception {
|
public void testExtractNetworkPortion() throws Exception {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"+17005554141",
|
"+17005554141",
|
||||||
PhoneNumberUtils.extractNetworkPortion("+17005554141")
|
PhoneNumberUtils.extractNetworkPortion("+17005554141")
|
||||||
@@ -180,6 +180,68 @@ public class PhoneNumberUtilsTest extends TestCase {
|
|||||||
assertNull(PhoneNumberUtils.stringFromStringAndTOA(null, 1));
|
assertNull(PhoneNumberUtils.stringFromStringAndTOA(null, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
public void testExtractNetworkPortionAlt() throws Exception {
|
||||||
|
assertEquals(
|
||||||
|
"+17005554141",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("+17005554141")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"+17005554141",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("+1 (700).555-4141")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"17005554141",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141")
|
||||||
|
);
|
||||||
|
|
||||||
|
// This may seem wrong, but it's probably ok
|
||||||
|
assertEquals(
|
||||||
|
"17005554141*#",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141*#")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"170055541NN",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"170055541NN",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN,1234")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"170055541NN",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN;1234")
|
||||||
|
);
|
||||||
|
|
||||||
|
// An MMI string is unperterbed, even though it contains a
|
||||||
|
// (valid in this case) embedded +
|
||||||
|
assertEquals(
|
||||||
|
"**21**+17005554141#",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("**21**+17005554141#")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"*31#+447966164208",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("*31#+447966164208")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"*31#+447966164208",
|
||||||
|
PhoneNumberUtils.extractNetworkPortionAlt("*31# (+44) 79 6616 4208")
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt(""));
|
||||||
|
|
||||||
|
assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt(",1234"));
|
||||||
|
|
||||||
|
assertNull(PhoneNumberUtils.extractNetworkPortionAlt(null));
|
||||||
|
}
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testB() throws Exception {
|
public void testB() throws Exception {
|
||||||
assertEquals("", PhoneNumberUtils.extractPostDialPortion("+17005554141"));
|
assertEquals("", PhoneNumberUtils.extractPostDialPortion("+17005554141"));
|
||||||
|
|||||||
Reference in New Issue
Block a user