diff options
| author | Hung-ying Tyan <tyanh@google.com> | 2010-09-17 16:58:51 +0800 |
|---|---|---|
| committer | Hung-ying Tyan <tyanh@google.com> | 2010-09-20 09:51:31 +0800 |
| commit | 97963794af1e18674dd111e3ad344d90b16c922c (patch) | |
| tree | 837c389d57da8ef0a39b2e480bd4f641a2f37ffb /voip/java/android/net/sip/SipAudioCallImpl.java | |
| parent | 5b930c49b12bdb1461a18491db768c642c38d498 (diff) | |
SIP: convert enum to static final int.
Converts SipErrorCode and SipSessionState.
Change-Id: Iee3a465649ea89d395b2336bbd673c25113e5f93
Diffstat (limited to 'voip/java/android/net/sip/SipAudioCallImpl.java')
| -rw-r--r-- | voip/java/android/net/sip/SipAudioCallImpl.java | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/voip/java/android/net/sip/SipAudioCallImpl.java b/voip/java/android/net/sip/SipAudioCallImpl.java index e61e8789b972..111bfff64ed1 100644 --- a/voip/java/android/net/sip/SipAudioCallImpl.java +++ b/voip/java/android/net/sip/SipAudioCallImpl.java @@ -81,7 +81,7 @@ public class SipAudioCallImpl extends SipSessionAdapter private WifiManager mWm; private WifiManager.WifiLock mWifiHighPerfLock; - private SipErrorCode mErrorCode; + private int mErrorCode = SipErrorCode.NO_ERROR; private String mErrorMessage; public SipAudioCallImpl(Context context, SipProfile localProfile) { @@ -100,7 +100,7 @@ public class SipAudioCallImpl extends SipSessionAdapter try { if ((listener == null) || !callbackImmediately) { // do nothing - } else if (mErrorCode != null) { + } else if (mErrorCode != SipErrorCode.NO_ERROR) { listener.onError(this, mErrorCode, mErrorMessage); } else if (mInCall) { if (mHold) { @@ -109,18 +109,18 @@ public class SipAudioCallImpl extends SipSessionAdapter listener.onCallEstablished(this); } } else { - SipSessionState state = getState(); + int state = getState(); switch (state) { - case READY_TO_CALL: + case SipSessionState.READY_TO_CALL: listener.onReadyToCall(this); break; - case INCOMING_CALL: + case SipSessionState.INCOMING_CALL: listener.onRinging(this, getPeerProfile(mSipSession)); break; - case OUTGOING_CALL: + case SipSessionState.OUTGOING_CALL: listener.onCalling(this); break; - case OUTGOING_CALL_RING_BACK: + case SipSessionState.OUTGOING_CALL_RING_BACK: listener.onRingingBack(this); break; } @@ -150,7 +150,7 @@ public class SipAudioCallImpl extends SipSessionAdapter mInCall = false; mHold = false; mSessionId = -1L; - mErrorCode = null; + mErrorCode = SipErrorCode.NO_ERROR; mErrorMessage = null; if (mSipSession != null) { @@ -175,10 +175,10 @@ public class SipAudioCallImpl extends SipSessionAdapter } } - public synchronized SipSessionState getState() { + public synchronized int getState() { if (mSipSession == null) return SipSessionState.READY_TO_CALL; try { - return Enum.valueOf(SipSessionState.class, mSipSession.getState()); + return mSipSession.getState(); } catch (RemoteException e) { return SipSessionState.REMOTE_ERROR; } @@ -294,15 +294,11 @@ public class SipAudioCallImpl extends SipSessionAdapter } } - private SipErrorCode getErrorCode(String errorCode) { - return Enum.valueOf(SipErrorCode.class, errorCode); - } - @Override - public void onCallChangeFailed(ISipSession session, String errorCode, + public void onCallChangeFailed(ISipSession session, int errorCode, String message) { Log.d(TAG, "sip call change failed: " + message); - mErrorCode = getErrorCode(errorCode); + mErrorCode = errorCode; mErrorMessage = message; Listener listener = mListener; if (listener != null) { @@ -315,10 +311,10 @@ public class SipAudioCallImpl extends SipSessionAdapter } @Override - public void onError(ISipSession session, String errorCodeString, - String message) { - Log.d(TAG, "sip session error: " + errorCodeString + ": " + message); - SipErrorCode errorCode = mErrorCode = getErrorCode(errorCodeString); + public void onError(ISipSession session, int errorCode, String message) { + Log.d(TAG, "sip session error: " + SipErrorCode.toString(errorCode) + + ": " + message); + mErrorCode = errorCode; mErrorMessage = message; synchronized (this) { if ((mErrorCode == SipErrorCode.DATA_CONNECTION_LOST) @@ -608,10 +604,10 @@ public class SipAudioCallImpl extends SipSessionAdapter try { startAudioInternal(); } catch (UnknownHostException e) { - onError(mSipSession, SipErrorCode.PEER_NOT_REACHABLE.toString(), + onError(mSipSession, SipErrorCode.PEER_NOT_REACHABLE, e.getMessage()); } catch (Throwable e) { - onError(mSipSession, SipErrorCode.CLIENT_ERROR.toString(), + onError(mSipSession, SipErrorCode.CLIENT_ERROR, e.getMessage()); } } |
