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

Commit 40c8c770 authored by Wink Saville's avatar Wink Saville Committed by Android (Google) Code Review
Browse files

Merge "Add debug and some cleanup"

parents ba7e0922 91e8659a
Loading
Loading
Loading
Loading
+56 −39
Original line number Original line Diff line number Diff line
@@ -25,17 +25,11 @@ import android.net.rtp.RtpStream;
import android.net.sip.SimpleSessionDescription.Media;
import android.net.sip.SimpleSessionDescription.Media;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager;
import android.os.Message;
import android.os.Message;
import android.os.RemoteException;
import android.telephony.Rlog;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;

import java.io.IOException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
/**
 * Handles an Internet audio call over SIP. You can instantiate this class with {@link SipManager},
 * Handles an Internet audio call over SIP. You can instantiate this class with {@link SipManager},
@@ -60,7 +54,8 @@ import java.util.Map;
 * </div>
 * </div>
 */
 */
public class SipAudioCall {
public class SipAudioCall {
    private static final String TAG = SipAudioCall.class.getSimpleName();
    private static final String LOG_TAG = SipAudioCall.class.getSimpleName();
    private static final boolean DBG = true;
    private static final boolean RELEASE_SOCKET = true;
    private static final boolean RELEASE_SOCKET = true;
    private static final boolean DONT_RELEASE_SOCKET = false;
    private static final boolean DONT_RELEASE_SOCKET = false;
    private static final int SESSION_TIMEOUT = 5; // in seconds
    private static final int SESSION_TIMEOUT = 5; // in seconds
@@ -191,7 +186,6 @@ public class SipAudioCall {
    private boolean mMuted = false;
    private boolean mMuted = false;
    private boolean mHold = false;
    private boolean mHold = false;


    private SipProfile mPendingCallRequest;
    private WifiManager mWm;
    private WifiManager mWm;
    private WifiManager.WifiLock mWifiHighPerfLock;
    private WifiManager.WifiLock mWifiHighPerfLock;


@@ -261,7 +255,7 @@ public class SipAudioCall {
                }
                }
            }
            }
        } catch (Throwable t) {
        } catch (Throwable t) {
            Log.e(TAG, "setListener()", t);
            loge("setListener()", t);
        }
        }
    }
    }


@@ -371,7 +365,7 @@ public class SipAudioCall {
                mAudioStream = new AudioStream(InetAddress.getByName(
                mAudioStream = new AudioStream(InetAddress.getByName(
                        getLocalIp()));
                        getLocalIp()));
            } catch (Throwable t) {
            } catch (Throwable t) {
                Log.i(TAG, "transferToNewSession(): " + t);
                loge("transferToNewSession():", t);
            }
            }
        }
        }
        if (origin != null) origin.endCall();
        if (origin != null) origin.endCall();
@@ -382,26 +376,26 @@ public class SipAudioCall {
        return new SipSession.Listener() {
        return new SipSession.Listener() {
            @Override
            @Override
            public void onCalling(SipSession session) {
            public void onCalling(SipSession session) {
                Log.d(TAG, "calling... " + session);
                if (DBG) log("onCalling: session=" + session);
                Listener listener = mListener;
                Listener listener = mListener;
                if (listener != null) {
                if (listener != null) {
                    try {
                    try {
                        listener.onCalling(SipAudioCall.this);
                        listener.onCalling(SipAudioCall.this);
                    } catch (Throwable t) {
                    } catch (Throwable t) {
                        Log.i(TAG, "onCalling(): " + t);
                        loge("onCalling():", t);
                    }
                    }
                }
                }
            }
            }


            @Override
            @Override
            public void onRingingBack(SipSession session) {
            public void onRingingBack(SipSession session) {
                Log.d(TAG, "sip call ringing back: " + session);
                if (DBG) log("onRingingBackk: " + session);
                Listener listener = mListener;
                Listener listener = mListener;
                if (listener != null) {
                if (listener != null) {
                    try {
                    try {
                        listener.onRingingBack(SipAudioCall.this);
                        listener.onRingingBack(SipAudioCall.this);
                    } catch (Throwable t) {
                    } catch (Throwable t) {
                        Log.i(TAG, "onRingingBack(): " + t);
                        loge("onRingingBack():", t);
                    }
                    }
                }
                }
            }
            }
@@ -424,7 +418,7 @@ public class SipAudioCall {
                        String answer = createAnswer(sessionDescription).encode();
                        String answer = createAnswer(sessionDescription).encode();
                        mSipSession.answerCall(answer, SESSION_TIMEOUT);
                        mSipSession.answerCall(answer, SESSION_TIMEOUT);
                    } catch (Throwable e) {
                    } catch (Throwable e) {
                        Log.e(TAG, "onRinging()", e);
                        loge("onRinging():", e);
                        session.endCall();
                        session.endCall();
                    }
                    }
                }
                }
@@ -434,7 +428,7 @@ public class SipAudioCall {
            public void onCallEstablished(SipSession session,
            public void onCallEstablished(SipSession session,
                    String sessionDescription) {
                    String sessionDescription) {
                mPeerSd = sessionDescription;
                mPeerSd = sessionDescription;
                Log.v(TAG, "onCallEstablished()" + mPeerSd);
                if (DBG) log("onCallEstablished(): " + mPeerSd);


                // TODO: how to notify the UI that the remote party is changed
                // TODO: how to notify the UI that the remote party is changed
                if ((mTransferringSession != null)
                if ((mTransferringSession != null)
@@ -452,14 +446,14 @@ public class SipAudioCall {
                            listener.onCallEstablished(SipAudioCall.this);
                            listener.onCallEstablished(SipAudioCall.this);
                        }
                        }
                    } catch (Throwable t) {
                    } catch (Throwable t) {
                        Log.i(TAG, "onCallEstablished(): " + t);
                        loge("onCallEstablished(): ", t);
                    }
                    }
                }
                }
            }
            }


            @Override
            @Override
            public void onCallEnded(SipSession session) {
            public void onCallEnded(SipSession session) {
                Log.d(TAG, "sip call ended: " + session + " mSipSession:" + mSipSession);
                if (DBG) log("onCallEnded: " + session + " mSipSession:" + mSipSession);
                // reset the trasnferring session if it is the one.
                // reset the trasnferring session if it is the one.
                if (session == mTransferringSession) {
                if (session == mTransferringSession) {
                    mTransferringSession = null;
                    mTransferringSession = null;
@@ -475,7 +469,7 @@ public class SipAudioCall {
                    try {
                    try {
                        listener.onCallEnded(SipAudioCall.this);
                        listener.onCallEnded(SipAudioCall.this);
                    } catch (Throwable t) {
                    } catch (Throwable t) {
                        Log.i(TAG, "onCallEnded(): " + t);
                        loge("onCallEnded(): ", t);
                    }
                    }
                }
                }
                close();
                close();
@@ -483,13 +477,13 @@ public class SipAudioCall {


            @Override
            @Override
            public void onCallBusy(SipSession session) {
            public void onCallBusy(SipSession session) {
                Log.d(TAG, "sip call busy: " + session);
                if (DBG) log("onCallBusy: " + session);
                Listener listener = mListener;
                Listener listener = mListener;
                if (listener != null) {
                if (listener != null) {
                    try {
                    try {
                        listener.onCallBusy(SipAudioCall.this);
                        listener.onCallBusy(SipAudioCall.this);
                    } catch (Throwable t) {
                    } catch (Throwable t) {
                        Log.i(TAG, "onCallBusy(): " + t);
                        loge("onCallBusy(): ", t);
                    }
                    }
                }
                }
                close(false);
                close(false);
@@ -498,7 +492,7 @@ public class SipAudioCall {
            @Override
            @Override
            public void onCallChangeFailed(SipSession session, int errorCode,
            public void onCallChangeFailed(SipSession session, int errorCode,
                    String message) {
                    String message) {
                Log.d(TAG, "sip call change failed: " + message);
                if (DBG) log("onCallChangedFailed: " + message);
                mErrorCode = errorCode;
                mErrorCode = errorCode;
                mErrorMessage = message;
                mErrorMessage = message;
                Listener listener = mListener;
                Listener listener = mListener;
@@ -507,7 +501,7 @@ public class SipAudioCall {
                        listener.onError(SipAudioCall.this, mErrorCode,
                        listener.onError(SipAudioCall.this, mErrorCode,
                                message);
                                message);
                    } catch (Throwable t) {
                    } catch (Throwable t) {
                        Log.i(TAG, "onCallBusy(): " + t);
                        loge("onCallBusy():", t);
                    }
                    }
                }
                }
            }
            }
@@ -542,8 +536,8 @@ public class SipAudioCall {
            @Override
            @Override
            public void onCallTransferring(SipSession newSession,
            public void onCallTransferring(SipSession newSession,
                    String sessionDescription) {
                    String sessionDescription) {
                Log.v(TAG, "onCallTransferring mSipSession:"
                if (DBG) log("onCallTransferring: mSipSession="
                        + mSipSession + " newSession:" + newSession);
                        + mSipSession + " newSession=" + newSession);
                mTransferringSession = newSession;
                mTransferringSession = newSession;
                try {
                try {
                    if (sessionDescription == null) {
                    if (sessionDescription == null) {
@@ -554,7 +548,7 @@ public class SipAudioCall {
                        newSession.answerCall(answer, SESSION_TIMEOUT);
                        newSession.answerCall(answer, SESSION_TIMEOUT);
                    }
                    }
                } catch (Throwable e) {
                } catch (Throwable e) {
                    Log.e(TAG, "onCallTransferring()", e);
                    loge("onCallTransferring()", e);
                    newSession.endCall();
                    newSession.endCall();
                }
                }
            }
            }
@@ -562,7 +556,7 @@ public class SipAudioCall {
    }
    }


    private void onError(int errorCode, String message) {
    private void onError(int errorCode, String message) {
        Log.d(TAG, "sip session error: "
        if (DBG) log("onError: "
                + SipErrorCode.toString(errorCode) + ": " + message);
                + SipErrorCode.toString(errorCode) + ": " + message);
        mErrorCode = errorCode;
        mErrorCode = errorCode;
        mErrorMessage = message;
        mErrorMessage = message;
@@ -571,7 +565,7 @@ public class SipAudioCall {
            try {
            try {
                listener.onError(this, errorCode, message);
                listener.onError(this, errorCode, message);
            } catch (Throwable t) {
            } catch (Throwable t) {
                Log.i(TAG, "onError(): " + t);
                loge("onError():", t);
            }
            }
        }
        }
        synchronized (this) {
        synchronized (this) {
@@ -600,11 +594,11 @@ public class SipAudioCall {
        synchronized (this) {
        synchronized (this) {
            mSipSession = session;
            mSipSession = session;
            mPeerSd = sessionDescription;
            mPeerSd = sessionDescription;
            Log.v(TAG, "attachCall()" + mPeerSd);
            if (DBG) log("attachCall(): " + mPeerSd);
            try {
            try {
                session.setListener(createListener());
                session.setListener(createListener());
            } catch (Throwable e) {
            } catch (Throwable e) {
                Log.e(TAG, "attachCall()", e);
                loge("attachCall()", e);
                throwSipException(e);
                throwSipException(e);
            }
            }
        }
        }
@@ -627,6 +621,7 @@ public class SipAudioCall {
     */
     */
    public void makeCall(SipProfile peerProfile, SipSession sipSession,
    public void makeCall(SipProfile peerProfile, SipSession sipSession,
            int timeout) throws SipException {
            int timeout) throws SipException {
        if (DBG) log("makeCall: " + peerProfile + " session=" + sipSession + " timeout=" + timeout);
        if (!SipManager.isVoipSupported(mContext)) {
        if (!SipManager.isVoipSupported(mContext)) {
            throw new SipException("VOIP API is not supported");
            throw new SipException("VOIP API is not supported");
        }
        }
@@ -640,6 +635,7 @@ public class SipAudioCall {
                sipSession.makeCall(peerProfile, createOffer().encode(),
                sipSession.makeCall(peerProfile, createOffer().encode(),
                        timeout);
                        timeout);
            } catch (IOException e) {
            } catch (IOException e) {
                loge("makeCall:", e);
                throw new SipException("makeCall()", e);
                throw new SipException("makeCall()", e);
            }
            }
        }
        }
@@ -650,6 +646,7 @@ public class SipAudioCall {
     * @throws SipException if the SIP service fails to end the call
     * @throws SipException if the SIP service fails to end the call
     */
     */
    public void endCall() throws SipException {
    public void endCall() throws SipException {
        if (DBG) log("endCall: mSipSession" + mSipSession);
        synchronized (this) {
        synchronized (this) {
            stopCall(RELEASE_SOCKET);
            stopCall(RELEASE_SOCKET);
            mInCall = false;
            mInCall = false;
@@ -672,9 +669,11 @@ public class SipAudioCall {
     * @throws SipException if the SIP service fails to hold the call
     * @throws SipException if the SIP service fails to hold the call
     */
     */
    public void holdCall(int timeout) throws SipException {
    public void holdCall(int timeout) throws SipException {
        if (DBG) log("holdCall: mSipSession" + mSipSession + " timeout=" + timeout);
        synchronized (this) {
        synchronized (this) {
            if (mHold) return;
            if (mHold) return;
            if (mSipSession == null) {
            if (mSipSession == null) {
                loge("holdCall:");
                throw new SipException("Not in a call to hold call");
                throw new SipException("Not in a call to hold call");
            }
            }
            mSipSession.changeCall(createHoldOffer().encode(), timeout);
            mSipSession.changeCall(createHoldOffer().encode(), timeout);
@@ -695,6 +694,7 @@ public class SipAudioCall {
     * @throws SipException if the SIP service fails to answer the call
     * @throws SipException if the SIP service fails to answer the call
     */
     */
    public void answerCall(int timeout) throws SipException {
    public void answerCall(int timeout) throws SipException {
        if (DBG) log("answerCall: mSipSession" + mSipSession + " timeout=" + timeout);
        synchronized (this) {
        synchronized (this) {
            if (mSipSession == null) {
            if (mSipSession == null) {
                throw new SipException("No call to answer");
                throw new SipException("No call to answer");
@@ -704,6 +704,7 @@ public class SipAudioCall {
                        getLocalIp()));
                        getLocalIp()));
                mSipSession.answerCall(createAnswer(mPeerSd).encode(), timeout);
                mSipSession.answerCall(createAnswer(mPeerSd).encode(), timeout);
            } catch (IOException e) {
            } catch (IOException e) {
                loge("answerCall:", e);
                throw new SipException("answerCall()", e);
                throw new SipException("answerCall()", e);
            }
            }
        }
        }
@@ -722,6 +723,7 @@ public class SipAudioCall {
     * @throws SipException if the SIP service fails to unhold the call
     * @throws SipException if the SIP service fails to unhold the call
     */
     */
    public void continueCall(int timeout) throws SipException {
    public void continueCall(int timeout) throws SipException {
        if (DBG) log("continueCall: mSipSession" + mSipSession + " timeout=" + timeout);
        synchronized (this) {
        synchronized (this) {
            if (!mHold) return;
            if (!mHold) return;
            mSipSession.changeCall(createContinueOffer().encode(), timeout);
            mSipSession.changeCall(createContinueOffer().encode(), timeout);
@@ -740,6 +742,7 @@ public class SipAudioCall {
            media.setRtpPayload(codec.type, codec.rtpmap, codec.fmtp);
            media.setRtpPayload(codec.type, codec.rtpmap, codec.fmtp);
        }
        }
        media.setRtpPayload(127, "telephone-event/8000", "0-15");
        media.setRtpPayload(127, "telephone-event/8000", "0-15");
        if (DBG) log("createOffer: offer=" + offer);
        return offer;
        return offer;
    }
    }


@@ -798,18 +801,22 @@ public class SipAudioCall {
            }
            }
        }
        }
        if (codec == null) {
        if (codec == null) {
            loge("createAnswer: no suitable codes");
            throw new IllegalStateException("Reject SDP: no suitable codecs");
            throw new IllegalStateException("Reject SDP: no suitable codecs");
        }
        }
        if (DBG) log("createAnswer: answer=" + answer);
        return answer;
        return answer;
    }
    }


    private SimpleSessionDescription createHoldOffer() {
    private SimpleSessionDescription createHoldOffer() {
        SimpleSessionDescription offer = createContinueOffer();
        SimpleSessionDescription offer = createContinueOffer();
        offer.setAttribute("sendonly", "");
        offer.setAttribute("sendonly", "");
        if (DBG) log("createHoldOffer: offer=" + offer);
        return offer;
        return offer;
    }
    }


    private SimpleSessionDescription createContinueOffer() {
    private SimpleSessionDescription createContinueOffer() {
        if (DBG) log("createContinueOffer");
        SimpleSessionDescription offer =
        SimpleSessionDescription offer =
                new SimpleSessionDescription(mSessionId, getLocalIp());
                new SimpleSessionDescription(mSessionId, getLocalIp());
        Media media = offer.newMedia(
        Media media = offer.newMedia(
@@ -825,17 +832,17 @@ public class SipAudioCall {


    private void grabWifiHighPerfLock() {
    private void grabWifiHighPerfLock() {
        if (mWifiHighPerfLock == null) {
        if (mWifiHighPerfLock == null) {
            Log.v(TAG, "acquire wifi high perf lock");
            if (DBG) log("grabWifiHighPerfLock:");
            mWifiHighPerfLock = ((WifiManager)
            mWifiHighPerfLock = ((WifiManager)
                    mContext.getSystemService(Context.WIFI_SERVICE))
                    mContext.getSystemService(Context.WIFI_SERVICE))
                    .createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, TAG);
                    .createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, LOG_TAG);
            mWifiHighPerfLock.acquire();
            mWifiHighPerfLock.acquire();
        }
        }
    }
    }


    private void releaseWifiHighPerfLock() {
    private void releaseWifiHighPerfLock() {
        if (mWifiHighPerfLock != null) {
        if (mWifiHighPerfLock != null) {
            Log.v(TAG, "release wifi high perf lock");
            if (DBG) log("releaseWifiHighPerfLock:");
            mWifiHighPerfLock.release();
            mWifiHighPerfLock.release();
            mWifiHighPerfLock = null;
            mWifiHighPerfLock = null;
        }
        }
@@ -912,7 +919,7 @@ public class SipAudioCall {
            AudioGroup audioGroup = getAudioGroup();
            AudioGroup audioGroup = getAudioGroup();
            if ((audioGroup != null) && (mSipSession != null)
            if ((audioGroup != null) && (mSipSession != null)
                    && (SipSession.State.IN_CALL == getState())) {
                    && (SipSession.State.IN_CALL == getState())) {
                Log.v(TAG, "send DTMF: " + code);
                if (DBG) log("sendDtmf: code=" + code + " result=" + result);
                audioGroup.sendDtmf(code);
                audioGroup.sendDtmf(code);
            }
            }
            if (result != null) result.sendToTarget();
            if (result != null) result.sendToTarget();
@@ -971,6 +978,7 @@ public class SipAudioCall {
     */
     */
    public void setAudioGroup(AudioGroup group) {
    public void setAudioGroup(AudioGroup group) {
        synchronized (this) {
        synchronized (this) {
            if (DBG) log("setAudioGroup: group=" + group);
            if ((mAudioStream != null) && (mAudioStream.getGroup() != null)) {
            if ((mAudioStream != null) && (mAudioStream.getGroup() != null)) {
                mAudioStream.join(group);
                mAudioStream.join(group);
            }
            }
@@ -997,8 +1005,8 @@ public class SipAudioCall {
    }
    }


    private synchronized void startAudioInternal() throws UnknownHostException {
    private synchronized void startAudioInternal() throws UnknownHostException {
        if (DBG) loge("startAudioInternal: mPeerSd=" + mPeerSd);
        if (mPeerSd == null) {
        if (mPeerSd == null) {
            Log.v(TAG, "startAudioInternal() mPeerSd = null");
            throw new IllegalStateException("mPeerSd = null");
            throw new IllegalStateException("mPeerSd = null");
        }
        }


@@ -1082,6 +1090,7 @@ public class SipAudioCall {
    // set audio group mode based on current audio configuration
    // set audio group mode based on current audio configuration
    private void setAudioGroupMode() {
    private void setAudioGroupMode() {
        AudioGroup audioGroup = getAudioGroup();
        AudioGroup audioGroup = getAudioGroup();
        if (DBG) log("setAudioGroupMode: audioGroup=" + audioGroup);
        if (audioGroup != null) {
        if (audioGroup != null) {
            if (mHold) {
            if (mHold) {
                audioGroup.setMode(AudioGroup.MODE_ON_HOLD);
                audioGroup.setMode(AudioGroup.MODE_ON_HOLD);
@@ -1096,7 +1105,7 @@ public class SipAudioCall {
    }
    }


    private void stopCall(boolean releaseSocket) {
    private void stopCall(boolean releaseSocket) {
        Log.d(TAG, "stop audiocall");
        if (DBG) log("stopCall: releaseSocket=" + releaseSocket);
        releaseWifiHighPerfLock();
        releaseWifiHighPerfLock();
        if (mAudioStream != null) {
        if (mAudioStream != null) {
            mAudioStream.join(null);
            mAudioStream.join(null);
@@ -1120,7 +1129,15 @@ public class SipAudioCall {
        }
        }
    }
    }


    private SipProfile getPeerProfile(SipSession session) {
    private void log(String s) {
        return session.getPeerProfile();
        Rlog.d(LOG_TAG, s);
    }

    private void loge(String s) {
        Rlog.e(LOG_TAG, s);
    }

    private void loge(String s, Throwable t) {
        Rlog.e(LOG_TAG, s, t);
    }
    }
}
}
+2 −3
Original line number Original line Diff line number Diff line
@@ -21,10 +21,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.util.Log;
import android.telephony.Rlog;


import java.text.ParseException;
import java.text.ParseException;


@@ -591,7 +590,7 @@ public class SipManager {
                        : session.getLocalProfile().getUriString());
                        : session.getLocalProfile().getUriString());
            } catch (Throwable e) {
            } catch (Throwable e) {
                // SipService died? SIP stack died?
                // SipService died? SIP stack died?
                Log.w(TAG, "getUri(): " + e);
                Rlog.e(TAG, "getUri(): ", e);
                return null;
                return null;
            }
            }
        }
        }
+31 −14
Original line number Original line Diff line number Diff line
@@ -17,7 +17,7 @@
package android.net.sip;
package android.net.sip;


import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.telephony.Rlog;


/**
/**
 * Represents a SIP session that is associated with a SIP dialog or a standalone
 * Represents a SIP session that is associated with a SIP dialog or a standalone
@@ -242,7 +242,7 @@ public final class SipSession {
            try {
            try {
                realSession.setListener(createListener());
                realSession.setListener(createListener());
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "SipSession.setListener(): " + e);
                loge("SipSession.setListener:", e);
            }
            }
        }
        }
    }
    }
@@ -261,7 +261,7 @@ public final class SipSession {
        try {
        try {
            return mSession.getLocalIp();
            return mSession.getLocalIp();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "getLocalIp(): " + e);
            loge("getLocalIp:", e);
            return "127.0.0.1";
            return "127.0.0.1";
        }
        }
    }
    }
@@ -275,7 +275,7 @@ public final class SipSession {
        try {
        try {
            return mSession.getLocalProfile();
            return mSession.getLocalProfile();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "getLocalProfile(): " + e);
            loge("getLocalProfile:", e);
            return null;
            return null;
        }
        }
    }
    }
@@ -290,7 +290,7 @@ public final class SipSession {
        try {
        try {
            return mSession.getPeerProfile();
            return mSession.getPeerProfile();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "getPeerProfile(): " + e);
            loge("getPeerProfile:", e);
            return null;
            return null;
        }
        }
    }
    }
@@ -305,7 +305,7 @@ public final class SipSession {
        try {
        try {
            return mSession.getState();
            return mSession.getState();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "getState(): " + e);
            loge("getState:", e);
            return State.NOT_DEFINED;
            return State.NOT_DEFINED;
        }
        }
    }
    }
@@ -319,7 +319,7 @@ public final class SipSession {
        try {
        try {
            return mSession.isInCall();
            return mSession.isInCall();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "isInCall(): " + e);
            loge("isInCall:", e);
            return false;
            return false;
        }
        }
    }
    }
@@ -333,7 +333,7 @@ public final class SipSession {
        try {
        try {
            return mSession.getCallId();
            return mSession.getCallId();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "getCallId(): " + e);
            loge("getCallId:", e);
            return null;
            return null;
        }
        }
    }
    }
@@ -364,7 +364,7 @@ public final class SipSession {
        try {
        try {
            mSession.register(duration);
            mSession.register(duration);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "register(): " + e);
            loge("register:", e);
        }
        }
    }
    }


@@ -381,7 +381,7 @@ public final class SipSession {
        try {
        try {
            mSession.unregister();
            mSession.unregister();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "unregister(): " + e);
            loge("unregister:", e);
        }
        }
    }
    }


@@ -402,7 +402,7 @@ public final class SipSession {
        try {
        try {
            mSession.makeCall(callee, sessionDescription, timeout);
            mSession.makeCall(callee, sessionDescription, timeout);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "makeCall(): " + e);
            loge("makeCall:", e);
        }
        }
    }
    }


@@ -420,7 +420,7 @@ public final class SipSession {
        try {
        try {
            mSession.answerCall(sessionDescription, timeout);
            mSession.answerCall(sessionDescription, timeout);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "answerCall(): " + e);
            loge("answerCall:", e);
        }
        }
    }
    }


@@ -436,7 +436,7 @@ public final class SipSession {
        try {
        try {
            mSession.endCall();
            mSession.endCall();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "endCall(): " + e);
            loge("endCall:", e);
        }
        }
    }
    }


@@ -453,7 +453,7 @@ public final class SipSession {
        try {
        try {
            mSession.changeCall(sessionDescription, timeout);
            mSession.changeCall(sessionDescription, timeout);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "changeCall(): " + e);
            loge("changeCall:", e);
        }
        }
    }
    }


@@ -463,12 +463,14 @@ public final class SipSession {


    private ISipSessionListener createListener() {
    private ISipSessionListener createListener() {
        return new ISipSessionListener.Stub() {
        return new ISipSessionListener.Stub() {
            @Override
            public void onCalling(ISipSession session) {
            public void onCalling(ISipSession session) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onCalling(SipSession.this);
                    mListener.onCalling(SipSession.this);
                }
                }
            }
            }


            @Override
            public void onRinging(ISipSession session, SipProfile caller,
            public void onRinging(ISipSession session, SipProfile caller,
                    String sessionDescription) {
                    String sessionDescription) {
                if (mListener != null) {
                if (mListener != null) {
@@ -477,12 +479,14 @@ public final class SipSession {
                }
                }
            }
            }


            @Override
            public void onRingingBack(ISipSession session) {
            public void onRingingBack(ISipSession session) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onRingingBack(SipSession.this);
                    mListener.onRingingBack(SipSession.this);
                }
                }
            }
            }


            @Override
            public void onCallEstablished(ISipSession session,
            public void onCallEstablished(ISipSession session,
                    String sessionDescription) {
                    String sessionDescription) {
                if (mListener != null) {
                if (mListener != null) {
@@ -491,18 +495,21 @@ public final class SipSession {
                }
                }
            }
            }


            @Override
            public void onCallEnded(ISipSession session) {
            public void onCallEnded(ISipSession session) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onCallEnded(SipSession.this);
                    mListener.onCallEnded(SipSession.this);
                }
                }
            }
            }


            @Override
            public void onCallBusy(ISipSession session) {
            public void onCallBusy(ISipSession session) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onCallBusy(SipSession.this);
                    mListener.onCallBusy(SipSession.this);
                }
                }
            }
            }


            @Override
            public void onCallTransferring(ISipSession session,
            public void onCallTransferring(ISipSession session,
                    String sessionDescription) {
                    String sessionDescription) {
                if (mListener != null) {
                if (mListener != null) {
@@ -513,6 +520,7 @@ public final class SipSession {
                }
                }
            }
            }


            @Override
            public void onCallChangeFailed(ISipSession session, int errorCode,
            public void onCallChangeFailed(ISipSession session, int errorCode,
                    String message) {
                    String message) {
                if (mListener != null) {
                if (mListener != null) {
@@ -521,24 +529,28 @@ public final class SipSession {
                }
                }
            }
            }


            @Override
            public void onError(ISipSession session, int errorCode, String message) {
            public void onError(ISipSession session, int errorCode, String message) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onError(SipSession.this, errorCode, message);
                    mListener.onError(SipSession.this, errorCode, message);
                }
                }
            }
            }


            @Override
            public void onRegistering(ISipSession session) {
            public void onRegistering(ISipSession session) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onRegistering(SipSession.this);
                    mListener.onRegistering(SipSession.this);
                }
                }
            }
            }


            @Override
            public void onRegistrationDone(ISipSession session, int duration) {
            public void onRegistrationDone(ISipSession session, int duration) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onRegistrationDone(SipSession.this, duration);
                    mListener.onRegistrationDone(SipSession.this, duration);
                }
                }
            }
            }


            @Override
            public void onRegistrationFailed(ISipSession session, int errorCode,
            public void onRegistrationFailed(ISipSession session, int errorCode,
                    String message) {
                    String message) {
                if (mListener != null) {
                if (mListener != null) {
@@ -547,6 +559,7 @@ public final class SipSession {
                }
                }
            }
            }


            @Override
            public void onRegistrationTimeout(ISipSession session) {
            public void onRegistrationTimeout(ISipSession session) {
                if (mListener != null) {
                if (mListener != null) {
                    mListener.onRegistrationTimeout(SipSession.this);
                    mListener.onRegistrationTimeout(SipSession.this);
@@ -554,4 +567,8 @@ public final class SipSession {
            }
            }
        };
        };
    }
    }

    private void loge(String s, Throwable t) {
        Rlog.e(TAG, s, t);
    }
}
}
Loading