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

Commit eaa511fd authored by repo sync's avatar repo sync Committed by Android (Google) Code Review
Browse files

Merge "resolved conflicts for merge of 12eaf9d5 to master"

parents 0525f95b 3d67c568
Loading
Loading
Loading
Loading
+9 −10
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import gov.nist.javax.sip.SipStackExt;
import gov.nist.javax.sip.clientauthutils.AccountManager;
import gov.nist.javax.sip.clientauthutils.AccountManager;
import gov.nist.javax.sip.clientauthutils.AuthenticationHelper;
import gov.nist.javax.sip.clientauthutils.AuthenticationHelper;


import android.net.sip.SessionDescription;
import android.net.sip.SipProfile;
import android.net.sip.SipProfile;
import android.util.Log;
import android.util.Log;


@@ -243,7 +242,7 @@ class SipHelper {
    }
    }


    public ClientTransaction sendInvite(SipProfile caller, SipProfile callee,
    public ClientTransaction sendInvite(SipProfile caller, SipProfile callee,
            SessionDescription sessionDescription, String tag)
            String sessionDescription, String tag)
            throws SipException {
            throws SipException {
        try {
        try {
            FromHeader fromHeader = createFromHeader(caller, tag);
            FromHeader fromHeader = createFromHeader(caller, tag);
@@ -259,9 +258,9 @@ class SipHelper {
                    toHeader, viaHeaders, maxForwards);
                    toHeader, viaHeaders, maxForwards);


            request.addHeader(createContactHeader(caller));
            request.addHeader(createContactHeader(caller));
            request.setContent(sessionDescription.getContent(),
            request.setContent(sessionDescription,
                    mHeaderFactory.createContentTypeHeader(
                    mHeaderFactory.createContentTypeHeader(
                            "application", sessionDescription.getType()));
                            "application", "sdp"));


            ClientTransaction clientTransaction =
            ClientTransaction clientTransaction =
                    mSipProvider.getNewClientTransaction(request);
                    mSipProvider.getNewClientTransaction(request);
@@ -273,12 +272,12 @@ class SipHelper {
    }
    }


    public ClientTransaction sendReinvite(Dialog dialog,
    public ClientTransaction sendReinvite(Dialog dialog,
            SessionDescription sessionDescription) throws SipException {
            String sessionDescription) throws SipException {
        try {
        try {
            Request request = dialog.createRequest(Request.INVITE);
            Request request = dialog.createRequest(Request.INVITE);
            request.setContent(sessionDescription.getContent(),
            request.setContent(sessionDescription,
                    mHeaderFactory.createContentTypeHeader(
                    mHeaderFactory.createContentTypeHeader(
                            "application", sessionDescription.getType()));
                            "application", "sdp"));


            ClientTransaction clientTransaction =
            ClientTransaction clientTransaction =
                    mSipProvider.getNewClientTransaction(request);
                    mSipProvider.getNewClientTransaction(request);
@@ -326,7 +325,7 @@ class SipHelper {
     * @param event the INVITE request event
     * @param event the INVITE request event
     */
     */
    public ServerTransaction sendInviteOk(RequestEvent event,
    public ServerTransaction sendInviteOk(RequestEvent event,
            SipProfile localProfile, SessionDescription sessionDescription,
            SipProfile localProfile, String sessionDescription,
            ServerTransaction inviteTransaction)
            ServerTransaction inviteTransaction)
            throws SipException {
            throws SipException {
        try {
        try {
@@ -334,9 +333,9 @@ class SipHelper {
            Response response = mMessageFactory.createResponse(Response.OK,
            Response response = mMessageFactory.createResponse(Response.OK,
                    request);
                    request);
            response.addHeader(createContactHeader(localProfile));
            response.addHeader(createContactHeader(localProfile));
            response.setContent(sessionDescription.getContent(),
            response.setContent(sessionDescription,
                    mHeaderFactory.createContentTypeHeader(
                    mHeaderFactory.createContentTypeHeader(
                            "application", sessionDescription.getType()));
                            "application", "sdp"));


            if (inviteTransaction == null) {
            if (inviteTransaction == null) {
                inviteTransaction = getServerTransaction(event);
                inviteTransaction = getServerTransaction(event);
+4 −1
Original line number Original line Diff line number Diff line
@@ -53,6 +53,9 @@ import java.util.TimerTask;
import java.util.TreeSet;
import java.util.TreeSet;
import javax.sip.SipException;
import javax.sip.SipException;


/**
 * @hide
 */
public final class SipService extends ISipService.Stub {
public final class SipService extends ISipService.Stub {
    private static final String TAG = "SipService";
    private static final String TAG = "SipService";
    private static final int EXPIRY_TIME = 3600;
    private static final int EXPIRY_TIME = 3600;
@@ -442,7 +445,7 @@ public final class SipService extends ISipService.Stub {


        @Override
        @Override
        public void onRinging(ISipSession session, SipProfile caller,
        public void onRinging(ISipSession session, SipProfile caller,
                byte[] sessionDescription) {
                String sessionDescription) {
            synchronized (SipService.this) {
            synchronized (SipService.this) {
                try {
                try {
                    if (!isRegistered()) {
                    if (!isRegistered()) {
+30 −13
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import gov.nist.javax.sip.clientauthutils.AccountManager;
import gov.nist.javax.sip.clientauthutils.UserCredentials;
import gov.nist.javax.sip.clientauthutils.UserCredentials;
import gov.nist.javax.sip.header.SIPHeaderNames;
import gov.nist.javax.sip.header.SIPHeaderNames;
import gov.nist.javax.sip.header.WWWAuthenticate;
import gov.nist.javax.sip.header.WWWAuthenticate;
import gov.nist.javax.sip.message.SIPMessage;


import android.net.sip.ISipSession;
import android.net.sip.ISipSession;
import android.net.sip.ISipSessionListener;
import android.net.sip.ISipSessionListener;
@@ -31,6 +32,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.Log;


import java.io.IOException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.DatagramSocket;
import java.net.DatagramSocket;
import java.text.ParseException;
import java.text.ParseException;
import java.util.Collection;
import java.util.Collection;
@@ -284,6 +286,22 @@ class SipSessionGroup implements SipListener {
        }
        }
    }
    }


    private String extractContent(Message message) {
        // Currently we do not support secure MIME bodies.
        byte[] bytes = message.getRawContent();
        if (bytes != null) {
            try {
                if (message instanceof SIPMessage) {
                    return ((SIPMessage) message).getMessageContent();
                } else {
                    return new String(bytes, "UTF-8");
                }
            } catch (UnsupportedEncodingException e) {
            }
        }
        return null;
    }

    private class SipSessionCallReceiverImpl extends SipSessionImpl {
    private class SipSessionCallReceiverImpl extends SipSessionImpl {
        public SipSessionCallReceiverImpl(ISipSessionListener listener) {
        public SipSessionCallReceiverImpl(ISipSessionListener listener) {
            super(listener);
            super(listener);
@@ -302,7 +320,7 @@ class SipSessionGroup implements SipListener {
                newSession.mPeerProfile = createPeerProfile(event.getRequest());
                newSession.mPeerProfile = createPeerProfile(event.getRequest());
                newSession.mState = SipSessionState.INCOMING_CALL;
                newSession.mState = SipSessionState.INCOMING_CALL;
                newSession.mPeerSessionDescription =
                newSession.mPeerSessionDescription =
                        event.getRequest().getRawContent();
                        extractContent(event.getRequest());
                addSipSession(newSession);
                addSipSession(newSession);
                mProxy.onRinging(newSession, newSession.mPeerProfile,
                mProxy.onRinging(newSession, newSession.mPeerProfile,
                        newSession.mPeerSessionDescription);
                        newSession.mPeerSessionDescription);
@@ -321,7 +339,7 @@ class SipSessionGroup implements SipListener {
        Dialog mDialog;
        Dialog mDialog;
        ServerTransaction mServerTransaction;
        ServerTransaction mServerTransaction;
        ClientTransaction mClientTransaction;
        ClientTransaction mClientTransaction;
        byte[] mPeerSessionDescription;
        String mPeerSessionDescription;
        boolean mInCall;
        boolean mInCall;
        boolean mReRegisterFlag = false;
        boolean mReRegisterFlag = false;


@@ -401,12 +419,12 @@ class SipSessionGroup implements SipListener {
        }
        }


        public void makeCall(SipProfile peerProfile,
        public void makeCall(SipProfile peerProfile,
                SessionDescription sessionDescription) {
                String sessionDescription) {
            doCommandAsync(
            doCommandAsync(
                    new MakeCallCommand(peerProfile, sessionDescription));
                    new MakeCallCommand(peerProfile, sessionDescription));
        }
        }


        public void answerCall(SessionDescription sessionDescription) {
        public void answerCall(String sessionDescription) {
            try {
            try {
                processCommand(
                processCommand(
                        new MakeCallCommand(mPeerProfile, sessionDescription));
                        new MakeCallCommand(mPeerProfile, sessionDescription));
@@ -419,7 +437,7 @@ class SipSessionGroup implements SipListener {
            doCommandAsync(END_CALL);
            doCommandAsync(END_CALL);
        }
        }


        public void changeCall(SessionDescription sessionDescription) {
        public void changeCall(String sessionDescription) {
            doCommandAsync(
            doCommandAsync(
                    new MakeCallCommand(mPeerProfile, sessionDescription));
                    new MakeCallCommand(mPeerProfile, sessionDescription));
        }
        }
@@ -726,10 +744,9 @@ class SipSessionGroup implements SipListener {
            if (evt instanceof MakeCallCommand) {
            if (evt instanceof MakeCallCommand) {
                MakeCallCommand cmd = (MakeCallCommand) evt;
                MakeCallCommand cmd = (MakeCallCommand) evt;
                mPeerProfile = cmd.getPeerProfile();
                mPeerProfile = cmd.getPeerProfile();
                SessionDescription sessionDescription =
                        cmd.getSessionDescription();
                mClientTransaction = mSipHelper.sendInvite(mLocalProfile,
                mClientTransaction = mSipHelper.sendInvite(mLocalProfile,
                        mPeerProfile, sessionDescription, generateTag());
                        mPeerProfile, cmd.getSessionDescription(),
                        generateTag());
                mDialog = mClientTransaction.getDialog();
                mDialog = mClientTransaction.getDialog();
                addSipSession(this);
                addSipSession(this);
                mState = SipSessionState.OUTGOING_CALL;
                mState = SipSessionState.OUTGOING_CALL;
@@ -811,7 +828,7 @@ class SipSessionGroup implements SipListener {
                    return true;
                    return true;
                case Response.OK:
                case Response.OK:
                    mSipHelper.sendInviteAck(event, mDialog);
                    mSipHelper.sendInviteAck(event, mDialog);
                    mPeerSessionDescription = response.getRawContent();
                    mPeerSessionDescription = extractContent(response);
                    establishCall();
                    establishCall();
                    return true;
                    return true;
                case Response.PROXY_AUTHENTICATION_REQUIRED:
                case Response.PROXY_AUTHENTICATION_REQUIRED:
@@ -897,7 +914,7 @@ class SipSessionGroup implements SipListener {
                // got Re-INVITE
                // got Re-INVITE
                RequestEvent event = mInviteReceived = (RequestEvent) evt;
                RequestEvent event = mInviteReceived = (RequestEvent) evt;
                mState = SipSessionState.INCOMING_CALL;
                mState = SipSessionState.INCOMING_CALL;
                mPeerSessionDescription = event.getRequest().getRawContent();
                mPeerSessionDescription = extractContent(event.getRequest());
                mServerTransaction = null;
                mServerTransaction = null;
                mProxy.onRinging(this, mPeerProfile, mPeerSessionDescription);
                mProxy.onRinging(this, mPeerProfile, mPeerSessionDescription);
                return true;
                return true;
@@ -1060,10 +1077,10 @@ class SipSessionGroup implements SipListener {
    }
    }


    private class MakeCallCommand extends EventObject {
    private class MakeCallCommand extends EventObject {
        private SessionDescription mSessionDescription;
        private String mSessionDescription;


        public MakeCallCommand(SipProfile peerProfile,
        public MakeCallCommand(SipProfile peerProfile,
                SessionDescription sessionDescription) {
                String sessionDescription) {
            super(peerProfile);
            super(peerProfile);
            mSessionDescription = sessionDescription;
            mSessionDescription = sessionDescription;
        }
        }
@@ -1072,7 +1089,7 @@ class SipSessionGroup implements SipListener {
            return (SipProfile) getSource();
            return (SipProfile) getSource();
        }
        }


        public SessionDescription getSessionDescription() {
        public String getSessionDescription() {
            return mSessionDescription;
            return mSessionDescription;
        }
        }
    }
    }
+2 −2
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
    }
    }


    public void onRinging(final ISipSession session, final SipProfile caller,
    public void onRinging(final ISipSession session, final SipProfile caller,
            final byte[] sessionDescription) {
            final String sessionDescription) {
        if (mListener == null) return;
        if (mListener == null) return;
        proxy(new Runnable() {
        proxy(new Runnable() {
            public void run() {
            public void run() {
@@ -83,7 +83,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
    }
    }


    public void onCallEstablished(final ISipSession session,
    public void onCallEstablished(final ISipSession session,
            final byte[] sessionDescription) {
            final String sessionDescription) {
        if (mListener == null) return;
        if (mListener == null) return;
        proxy(new Runnable() {
        proxy(new Runnable() {
            public void run() {
            public void run() {
+3 −4
Original line number Original line Diff line number Diff line
@@ -115,8 +115,7 @@ interface ISipSession {
     * @param sessionDescription the session description of this call
     * @param sessionDescription the session description of this call
     * @see ISipSessionListener
     * @see ISipSessionListener
     */
     */
    void makeCall(in SipProfile callee,
    void makeCall(in SipProfile callee, String sessionDescription);
            in SessionDescription sessionDescription);


    /**
    /**
     * Answers an incoming call with the specified session description. The
     * Answers an incoming call with the specified session description. The
@@ -125,7 +124,7 @@ interface ISipSession {
     *
     *
     * @param sessionDescription the session description to answer this call
     * @param sessionDescription the session description to answer this call
     */
     */
    void answerCall(in SessionDescription sessionDescription);
    void answerCall(String sessionDescription);


    /**
    /**
     * Ends an established call, terminates an outgoing call or rejects an
     * Ends an established call, terminates an outgoing call or rejects an
@@ -143,5 +142,5 @@ interface ISipSession {
     *
     *
     * @param sessionDescription the new session description
     * @param sessionDescription the new session description
     */
     */
    void changeCall(in SessionDescription sessionDescription);
    void changeCall(String sessionDescription);
}
}
Loading