Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd1c3c9e authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "SipProfile: Add configurable User-Agent" into gingerbread

parents 94c9a245 94735ac8
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
    private String mDomain;
    private String mProtocol = ListeningPoint.UDP;
    private String mProfileName;
    private String mUserAgent;
    private boolean mSendKeepAlive = false;
    private boolean mAutoRegistration = true;
    private transient int mCallingUid = 0;
@@ -70,6 +71,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
        private SipURI mUri;
        private String mDisplayName;
        private String mProxyAddress;
        private String mUserAgent;

        {
            try {
@@ -95,6 +97,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
            mUri.setUserPassword(profile.getPassword());
            mDisplayName = profile.getDisplayName();
            mProxyAddress = profile.getProxyAddress();
            mUserAgent = profile.getUserAgent();
        }

        /**
@@ -248,6 +251,18 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
            return this;
        }

        /**
         * Sets the user-agent header for SIP calls
         *
         * @param userAgent the string that'll be placed in the headers
         * @return this builder object
         * @hide
         */
        public Builder setUserAgent(String userAgent) {
            mUserAgent = userAgent;
            return this;
        }

        /**
         * Builds and returns the SIP profile object.
         *
@@ -265,6 +280,11 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
                            mAddressFactory.createURI(fix(mProxyAddress));
                    mProfile.mProxyAddress = uri.getHost();
                }
                if (!TextUtils.isEmpty(mUserAgent)) {
                    mProfile.mUserAgent = mUserAgent;
                } else {
                    mProfile.mUserAgent = "SIPAUA/0.1.001";
                }
            } catch (ParseException e) {
                // must not occur
                throw new RuntimeException(e);
@@ -283,6 +303,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
        mDomain = in.readString();
        mProtocol = in.readString();
        mProfileName = in.readString();
        mUserAgent = in.readString();
        mSendKeepAlive = (in.readInt() == 0) ? false : true;
        mAutoRegistration = (in.readInt() == 0) ? false : true;
        mCallingUid = in.readInt();
@@ -296,6 +317,7 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
        out.writeString(mDomain);
        out.writeString(mProtocol);
        out.writeString(mProfileName);
        out.writeString(mUserAgent);
        out.writeInt(mSendKeepAlive ? 1 : 0);
        out.writeInt(mAutoRegistration ? 1 : 0);
        out.writeInt(mCallingUid);
@@ -426,6 +448,16 @@ public class SipProfile implements Parcelable, Serializable, Cloneable {
        return mAutoRegistration;
    }

    /**
     * Gets the user-agent to apply to requests
     *
     * @return the UA string
     * @hide
     */
    public String getUserAgent() {
        return mUserAgent;
    }

    /**
     * Sets the calling process's Uid in the sip service.
     * @hide
+6 −1
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ class SipHelper {
                requestType, callIdHeader, cSeqHeader, fromHeader,
                toHeader, viaHeaders, maxForwards);
        Header userAgentHeader = mHeaderFactory.createHeader("User-Agent",
                "SIPAUA/0.1.001");
                userProfile.getUserAgent());
        request.addHeader(userAgentHeader);
        return request;
    }
@@ -260,6 +260,11 @@ class SipHelper {
                    Request.INVITE, callIdHeader, cSeqHeader, fromHeader,
                    toHeader, viaHeaders, maxForwards);


            Header userAgentHeader = mHeaderFactory.createHeader("User-Agent",
                    caller.getUserAgent());
            request.addHeader(userAgentHeader);

            request.addHeader(createContactHeader(caller));
            request.setContent(sessionDescription,
                    mHeaderFactory.createContentTypeHeader(