Merge "Throw proper exceptions in SipManager" into gingerbread

This commit is contained in:
Hung-ying Tyan
2010-11-30 00:51:22 -08:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 9 deletions

View File

@ -390,12 +390,11 @@ public class SipPhone extends SipPhoneBase {
new SipProfile.Builder(calleeSipUri).build(); new SipProfile.Builder(calleeSipUri).build();
SipConnection c = new SipConnection(this, callee, SipConnection c = new SipConnection(this, callee,
originalNumber); originalNumber);
connections.add(c);
c.dial(); c.dial();
connections.add(c);
setState(Call.State.DIALING); setState(Call.State.DIALING);
return c; return c;
} catch (ParseException e) { } catch (ParseException e) {
// TODO: notify someone
throw new SipException("dial", e); throw new SipException("dial", e);
} }
} }

View File

@ -314,10 +314,6 @@ public class SipManager {
SipAudioCall call = new SipAudioCall(mContext, localProfile); SipAudioCall call = new SipAudioCall(mContext, localProfile);
call.setListener(listener); call.setListener(listener);
SipSession s = createSipSession(localProfile, null); SipSession s = createSipSession(localProfile, null);
if (s == null) {
throw new SipException(
"Failed to create SipSession; network available?");
}
call.makeCall(peerProfile, s, timeout); call.makeCall(peerProfile, s, timeout);
return call; return call;
} }
@ -366,7 +362,9 @@ public class SipManager {
*/ */
public SipAudioCall takeAudioCall(Intent incomingCallIntent, public SipAudioCall takeAudioCall(Intent incomingCallIntent,
SipAudioCall.Listener listener) throws SipException { SipAudioCall.Listener listener) throws SipException {
if (incomingCallIntent == null) return null; if (incomingCallIntent == null) {
throw new SipException("Cannot retrieve session with null intent");
}
String callId = getCallId(incomingCallIntent); String callId = getCallId(incomingCallIntent);
if (callId == null) { if (callId == null) {
@ -381,7 +379,9 @@ public class SipManager {
try { try {
ISipSession session = mSipService.getPendingSession(callId); ISipSession session = mSipService.getPendingSession(callId);
if (session == null) return null; if (session == null) {
throw new SipException("No pending session for the call");
}
SipAudioCall call = new SipAudioCall( SipAudioCall call = new SipAudioCall(
mContext, session.getLocalProfile()); mContext, session.getLocalProfile());
call.attachCall(new SipSession(session), offerSd); call.attachCall(new SipSession(session), offerSd);
@ -526,6 +526,10 @@ public class SipManager {
SipSession.Listener listener) throws SipException { SipSession.Listener listener) throws SipException {
try { try {
ISipSession s = mSipService.createSession(localProfile, null); ISipSession s = mSipService.createSession(localProfile, null);
if (s == null) {
throw new SipException(
"Failed to create SipSession; network unavailable?");
}
return new SipSession(s, listener); return new SipSession(s, listener);
} catch (RemoteException e) { } catch (RemoteException e) {
throw new SipException("createSipSession()", e); throw new SipException("createSipSession()", e);
@ -541,7 +545,7 @@ public class SipManager {
try { try {
return mSipService.getListOfProfiles(); return mSipService.getListOfProfiles();
} catch (RemoteException e) { } catch (RemoteException e) {
return null; return new SipProfile[0];
} }
} }