Making it possible to call SIP calls with special allowed chars.

Since String.replaceFirst uses regex and since SIP user names are
allowed to include regex charaters such as '+', the code must
fist convert the string to a literal pattern String before using
replaceFirst method.

Change-Id: I25eac852bd620724ca1c5b2befc023af9dae3c1a
This commit is contained in:
Magnus Strandberg
2011-03-22 08:03:58 +01:00
committed by Johan Redestig
parent d973bed36c
commit b5c72ead01
2 changed files with 9 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ import com.android.internal.telephony.UUSInfo;
import java.text.ParseException;
import java.util.List;
import java.util.regex.Pattern;
/**
* {@hide}
@@ -383,8 +384,8 @@ public class SipPhone extends SipPhoneBase {
Connection dial(String originalNumber) throws SipException {
String calleeSipUri = originalNumber;
if (!calleeSipUri.contains("@")) {
calleeSipUri = mProfile.getUriString().replaceFirst(
mProfile.getUserName() + "@",
String replaceStr = Pattern.quote(mProfile.getUserName() + "@");
calleeSipUri = mProfile.getUriString().replaceFirst(replaceStr,
calleeSipUri + "@");
}
try {

View File

@@ -27,6 +27,8 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import java.util.regex.Pattern;
import javax.sip.ClientTransaction;
import javax.sip.Dialog;
import javax.sip.DialogTerminatedEvent;
@@ -215,9 +217,11 @@ class SipHelper {
String tag) throws ParseException, SipException {
FromHeader fromHeader = createFromHeader(userProfile, tag);
ToHeader toHeader = createToHeader(userProfile);
String replaceStr = Pattern.quote(userProfile.getUserName() + "@");
SipURI requestURI = mAddressFactory.createSipURI(
userProfile.getUriString().replaceFirst(
userProfile.getUserName() + "@", ""));
userProfile.getUriString().replaceFirst(replaceStr, ""));
List<ViaHeader> viaHeaders = createViaHeaders();
CallIdHeader callIdHeader = createCallIdHeader();
CSeqHeader cSeqHeader = createCSeqHeader(requestType);