summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2010-11-03 13:11:53 +0800
committerChung-yih Wang <cywang@google.com>2010-12-07 10:36:19 +0800
commitf053292d7a46c30abbe6f12ca04dbc03ec964d80 (patch)
tree103509a15cb400ce8a3593dfab235557c3276238
parentdaef0a040de7a9825bdbcba7b2eae66195e3a95f (diff)
downloadframeworks_base-f053292d7a46c30abbe6f12ca04dbc03ec964d80.zip
frameworks_base-f053292d7a46c30abbe6f12ca04dbc03ec964d80.tar.gz
frameworks_base-f053292d7a46c30abbe6f12ca04dbc03ec964d80.tar.bz2
Fix SIP bug of different transport/port used for requests.
bug: http://b/3156148 Change-Id: I4fa5b274d2e90ebde12d9e99822dc193a65bad32
-rwxr-xr-xtelephony/java/com/android/internal/telephony/sip/SipPhone.java4
-rw-r--r--voip/java/android/net/sip/SipProfile.java50
-rw-r--r--voip/java/com/android/server/sip/SipHelper.java5
3 files changed, 44 insertions, 15 deletions
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
index 5cf2531..a92ac1c 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
@@ -383,7 +383,9 @@ public class SipPhone extends SipPhoneBase {
Connection dial(String originalNumber) throws SipException {
String calleeSipUri = originalNumber;
if (!calleeSipUri.contains("@")) {
- calleeSipUri += "@" + getSipDomain(mProfile);
+ calleeSipUri = mProfile.getUriString().replaceFirst(
+ mProfile.getUserName() + "@",
+ calleeSipUri + "@");
}
try {
SipProfile callee =
diff --git a/voip/java/android/net/sip/SipProfile.java b/voip/java/android/net/sip/SipProfile.java
index 6977e30..4029ed0 100644
--- a/voip/java/android/net/sip/SipProfile.java
+++ b/voip/java/android/net/sip/SipProfile.java
@@ -20,6 +20,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
+import java.io.ObjectStreamException;
import java.io.Serializable;
import java.text.ParseException;
import javax.sip.InvalidArgumentException;
@@ -40,12 +41,15 @@ import javax.sip.address.URI;
public class SipProfile implements Parcelable, Serializable, Cloneable {
private static final long serialVersionUID = 1L;
private static final int DEFAULT_PORT = 5060;
+ private static final String TCP = "TCP";
+ private static final String UDP = "UDP";
private Address mAddress;
private String mProxyAddress;
private String mPassword;
private String mDomain;
- private String mProtocol = ListeningPoint.UDP;
+ private String mProtocol = UDP;
private String mProfileName;
+ private int mPort = DEFAULT_PORT;
private boolean mSendKeepAlive = false;
private boolean mAutoRegistration = true;
private transient int mCallingUid = 0;
@@ -95,6 +99,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
mUri.setUserPassword(profile.getPassword());
mDisplayName = profile.getDisplayName();
mProxyAddress = profile.getProxyAddress();
+ mProfile.mPort = profile.getPort();
}
/**
@@ -171,12 +176,11 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
* @throws IllegalArgumentException if the port number is out of range
*/
public Builder setPort(int port) throws IllegalArgumentException {
- try {
- mUri.setPort(port);
- return this;
- } catch (InvalidArgumentException e) {
- throw new IllegalArgumentException(e);
+ if ((port > 65535) || (port < 1000)) {
+ throw new IllegalArgumentException("incorrect port arugment");
}
+ mProfile.mPort = port;
+ return this;
}
/**
@@ -193,7 +197,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
throw new NullPointerException("protocol cannot be null");
}
protocol = protocol.toUpperCase();
- if (!protocol.equals("UDP") && !protocol.equals("TCP")) {
+ if (!protocol.equals(UDP) && !protocol.equals(TCP)) {
throw new IllegalArgumentException(
"unsupported protocol: " + protocol);
}
@@ -258,13 +262,22 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
mProfile.mPassword = mUri.getUserPassword();
mUri.setUserPassword(null);
try {
- mProfile.mAddress = mAddressFactory.createAddress(
- mDisplayName, mUri);
if (!TextUtils.isEmpty(mProxyAddress)) {
SipURI uri = (SipURI)
mAddressFactory.createURI(fix(mProxyAddress));
mProfile.mProxyAddress = uri.getHost();
+ } else {
+ if (!mProfile.mProtocol.equals(UDP)) {
+ mUri.setTransportParam(mProfile.mProtocol);
+ }
+ if (mProfile.mPort != DEFAULT_PORT) {
+ mUri.setPort(mProfile.mPort);
+ }
}
+ mProfile.mAddress = mAddressFactory.createAddress(
+ mDisplayName, mUri);
+ } catch (InvalidArgumentException e) {
+ throw new RuntimeException(e);
} catch (ParseException e) {
// must not occur
throw new RuntimeException(e);
@@ -286,6 +299,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
mSendKeepAlive = (in.readInt() == 0) ? false : true;
mAutoRegistration = (in.readInt() == 0) ? false : true;
mCallingUid = in.readInt();
+ mPort = in.readInt();
}
@Override
@@ -299,6 +313,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
out.writeInt(mSendKeepAlive ? 1 : 0);
out.writeInt(mAutoRegistration ? 1 : 0);
out.writeInt(mCallingUid);
+ out.writeInt(mPort);
}
@Override
@@ -322,7 +337,13 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
* @return the SIP URI string of this profile
*/
public String getUriString() {
- return mAddress.getURI().toString();
+ // We need to return the sip uri domain instead of
+ // the SIP URI with transport, port information if
+ // the outbound proxy address exists.
+ if (!TextUtils.isEmpty(mProxyAddress)) {
+ return "sip:" + getUserName() + "@" + mDomain;
+ }
+ return getUri().toString();
}
/**
@@ -377,8 +398,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
* @return the port number of the SIP server
*/
public int getPort() {
- int port = getUri().getPort();
- return (port == -1) ? DEFAULT_PORT : port;
+ return mPort;
}
/**
@@ -441,4 +461,10 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
public int getCallingUid() {
return mCallingUid;
}
+
+ private Object readResolve() throws ObjectStreamException {
+ // For compatibility.
+ if (mPort == 0) mPort = DEFAULT_PORT;
+ return this;
+ }
}
diff --git a/voip/java/com/android/server/sip/SipHelper.java b/voip/java/com/android/server/sip/SipHelper.java
index 13e6f14..518543a 100644
--- a/voip/java/com/android/server/sip/SipHelper.java
+++ b/voip/java/com/android/server/sip/SipHelper.java
@@ -215,8 +215,9 @@ class SipHelper {
String tag) throws ParseException, SipException {
FromHeader fromHeader = createFromHeader(userProfile, tag);
ToHeader toHeader = createToHeader(userProfile);
- SipURI requestURI = mAddressFactory.createSipURI("sip:"
- + userProfile.getSipDomain());
+ SipURI requestURI = mAddressFactory.createSipURI(
+ userProfile.getUriString().replaceFirst(
+ userProfile.getUserName() + "@", ""));
List<ViaHeader> viaHeaders = createViaHeaders();
CallIdHeader callIdHeader = createCallIdHeader();
CSeqHeader cSeqHeader = createCSeqHeader(requestType);