Merge "Add auth. username in SipProfile." into gingerbread

This commit is contained in:
Chung-yih Wang
2011-01-11 02:08:19 -08:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
private String mDomain; private String mDomain;
private String mProtocol = UDP; private String mProtocol = UDP;
private String mProfileName; private String mProfileName;
private String mAuthUserName;
private int mPort = DEFAULT_PORT; private int mPort = DEFAULT_PORT;
private boolean mSendKeepAlive = false; private boolean mSendKeepAlive = false;
private boolean mAutoRegistration = true; private boolean mAutoRegistration = true;
@@ -146,6 +147,18 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
: "sip:" + uriString); : "sip:" + uriString);
} }
/**
* Sets the username used for authentication.
*
* @param name auth. name of the profile
* @return this builder object
* @hide // TODO: remove when we make it public
*/
public Builder setAuthUserName(String name) {
mProfile.mAuthUserName = name;
return this;
}
/** /**
* Sets the name of the profile. This name is given by user. * Sets the name of the profile. This name is given by user.
* *
@@ -300,6 +313,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
mAutoRegistration = (in.readInt() == 0) ? false : true; mAutoRegistration = (in.readInt() == 0) ? false : true;
mCallingUid = in.readInt(); mCallingUid = in.readInt();
mPort = in.readInt(); mPort = in.readInt();
mAuthUserName = in.readString();
} }
@Override @Override
@@ -314,6 +328,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
out.writeInt(mAutoRegistration ? 1 : 0); out.writeInt(mAutoRegistration ? 1 : 0);
out.writeInt(mCallingUid); out.writeInt(mCallingUid);
out.writeInt(mPort); out.writeInt(mPort);
out.writeString(mAuthUserName);
} }
@Override @Override
@@ -374,6 +389,17 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
return getUri().getUser(); return getUri().getUser();
} }
/**
* Gets the username for authentication. If it is null, then the username
* should be used in authentication instead.
*
* @return the auth. username
* @hide // TODO: remove when we make it public
*/
public String getAuthUserName() {
return mAuthUserName;
}
/** /**
* Gets the password. * Gets the password.
* *

View File

@@ -895,7 +895,9 @@ class SipSessionGroup implements SipListener {
challengedTransaction, String realm) { challengedTransaction, String realm) {
return new UserCredentials() { return new UserCredentials() {
public String getUserName() { public String getUserName() {
return mLocalProfile.getUserName(); String username = mLocalProfile.getAuthUserName();
return (!TextUtils.isEmpty(username) ? username :
mLocalProfile.getUserName());
} }
public String getPassword() { public String getPassword() {