summaryrefslogtreecommitdiffstats
path: root/voip/java
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2010-12-06 23:36:23 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-12-06 23:36:23 -0800
commitc030a164c8a890947985d15722fe3df8785f7d04 (patch)
tree91e0a4350bfdcb4bbd231dbba4c722f87e14f02d /voip/java
parent6fa74a54346d136294593a4e60d3a59d94b3493c (diff)
parentc9cc9ab590ef879877e466c0b5f5823e11bb4c47 (diff)
downloadframeworks_base-c030a164c8a890947985d15722fe3df8785f7d04.zip
frameworks_base-c030a164c8a890947985d15722fe3df8785f7d04.tar.gz
frameworks_base-c030a164c8a890947985d15722fe3df8785f7d04.tar.bz2
am c9cc9ab5: am 5f86d7f5: Merge "Fix SIP bug of different transport/port used for requests." into gingerbread
* commit 'c9cc9ab590ef879877e466c0b5f5823e11bb4c47': Fix SIP bug of different transport/port used for requests.
Diffstat (limited to 'voip/java')
-rw-r--r--voip/java/android/net/sip/SipProfile.java50
-rw-r--r--voip/java/com/android/server/sip/SipHelper.java5
2 files changed, 41 insertions, 14 deletions
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);