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

Commit 37f709ae authored by Hung-ying Tyan's avatar Hung-ying Tyan Committed by Android (Google) Code Review
Browse files

Merge "SipProfile: add isOutgoingCallAllowed() and new builder constructor" into gingerbread

parents bfc9325f cf95f5d2
Loading
Loading
Loading
Loading
+40 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ import javax.sip.address.URI;
 * Class containing a SIP account, domain and server information.
 * @hide
 */
public class SipProfile implements Parcelable, Serializable {
public class SipProfile implements Parcelable, Serializable, Cloneable {
    private static final long serialVersionUID = 1L;
    private static final int DEFAULT_PORT = 5060;
    private Address mAddress;
@@ -46,6 +46,7 @@ public class SipProfile implements Parcelable, Serializable {
    private String mProfileName;
    private boolean mSendKeepAlive = false;
    private boolean mAutoRegistration = true;
    private boolean mAllowOutgoingCall = false;

    /** @hide */
    public static final Parcelable.Creator<SipProfile> CREATOR =
@@ -78,6 +79,23 @@ public class SipProfile implements Parcelable, Serializable {
            }
        }

        /**
         * Creates a builder based on the given profile.
         */
        public Builder(SipProfile profile) {
            if (profile == null) throw new NullPointerException();
            try {
                mProfile = (SipProfile) profile.clone();
            } catch (CloneNotSupportedException e) {
                throw new RuntimeException("should not occur", e);
            }
            mProfile.mAddress = null;
            mUri = profile.getUri();
            mUri.setUserPassword(profile.getPassword());
            mDisplayName = profile.getDisplayName();
            mProxyAddress = profile.getProxyAddress();
        }

        /**
         * Constructor.
         *
@@ -225,6 +243,18 @@ public class SipProfile implements Parcelable, Serializable {
            return this;
        }

        /**
         * Sets the allow-outgoing-call flag.
         *
         * @param flag true if allowing to make outgoing call on the profile;
         *      false otherwise
         * @return this builder object
         */
        public Builder setOutgoingCallAllowed(boolean flag) {
            mProfile.mAllowOutgoingCall = flag;
            return this;
        }

        /**
         * Builds and returns the SIP profile object.
         *
@@ -262,6 +292,7 @@ public class SipProfile implements Parcelable, Serializable {
        mProfileName = in.readString();
        mSendKeepAlive = (in.readInt() == 0) ? false : true;
        mAutoRegistration = (in.readInt() == 0) ? false : true;
        mAllowOutgoingCall = (in.readInt() == 0) ? false : true;
    }

    /** @hide */
@@ -274,6 +305,7 @@ public class SipProfile implements Parcelable, Serializable {
        out.writeString(mProfileName);
        out.writeInt(mSendKeepAlive ? 1 : 0);
        out.writeInt(mAutoRegistration ? 1 : 0);
        out.writeInt(mAllowOutgoingCall ? 1 : 0);
    }

    /** @hide */
@@ -398,4 +430,11 @@ public class SipProfile implements Parcelable, Serializable {
    public boolean getAutoRegistration() {
        return mAutoRegistration;
    }

    /**
     * Returns true if allowing to make outgoing calls on this profile.
     */
    public boolean isOutgoingCallAllowed() {
        return mAllowOutgoingCall;
    }
}