diff --git a/voip/java/android/net/sip/SipProfile.java b/voip/java/android/net/sip/SipProfile.java index f8fd2b7b61f19..c7e18dfbae65b 100644 --- a/voip/java/android/net/sip/SipProfile.java +++ b/voip/java/android/net/sip/SipProfile.java @@ -49,6 +49,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable { private String mDomain; private String mProtocol = UDP; private String mProfileName; + private String mAuthUserName; private int mPort = DEFAULT_PORT; private boolean mSendKeepAlive = false; private boolean mAutoRegistration = true; @@ -146,6 +147,18 @@ public class SipProfile implements Parcelable, Serializable, Cloneable { : "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. * @@ -300,6 +313,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable { mAutoRegistration = (in.readInt() == 0) ? false : true; mCallingUid = in.readInt(); mPort = in.readInt(); + mAuthUserName = in.readString(); } @Override @@ -314,6 +328,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable { out.writeInt(mAutoRegistration ? 1 : 0); out.writeInt(mCallingUid); out.writeInt(mPort); + out.writeString(mAuthUserName); } @Override @@ -374,6 +389,17 @@ public class SipProfile implements Parcelable, Serializable, Cloneable { 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. * diff --git a/voip/java/com/android/server/sip/SipSessionGroup.java b/voip/java/com/android/server/sip/SipSessionGroup.java index 3275317775740..aa616a9e0fa12 100644 --- a/voip/java/com/android/server/sip/SipSessionGroup.java +++ b/voip/java/com/android/server/sip/SipSessionGroup.java @@ -895,7 +895,9 @@ class SipSessionGroup implements SipListener { challengedTransaction, String realm) { return new UserCredentials() { public String getUserName() { - return mLocalProfile.getUserName(); + String username = mLocalProfile.getAuthUserName(); + return (!TextUtils.isEmpty(username) ? username : + mLocalProfile.getUserName()); } public String getPassword() {