Catch exceptions in SipPhone.canTake().

Exceptions may throw during canTake() as the peer may cancel the call and
result in a race with this method call.

Change-Id: I61903d601d8f9b2dcb4c4fbe1586e2c1a1069109
http://b/issue?id=3033868
This commit is contained in:
Hung-ying Tyan
2010-09-28 10:02:36 +08:00
parent 421c34c162
commit 0e41230481

View File

@ -126,15 +126,28 @@ public class SipPhone extends SipPhoneBase {
return false;
}
try {
SipAudioCall sipAudioCall = (SipAudioCall) incomingCall;
Log.v(LOG_TAG, " ++++++ taking call from: "
Log.d(LOG_TAG, "+++ taking call from: "
+ sipAudioCall.getPeerProfile().getUriString());
String localUri = sipAudioCall.getLocalProfile().getUriString();
if (localUri.equals(mProfile.getUriString())) {
boolean makeCallWait = foregroundCall.getState().isAlive();
ringingCall.initIncomingCall(sipAudioCall, makeCallWait);
if (sipAudioCall.getState()
!= SipSession.State.INCOMING_CALL) {
// Peer cancelled the call!
Log.d(LOG_TAG, " call cancelled !!");
ringingCall.reset();
}
return true;
}
} catch (Exception e) {
// Peer may cancel the call at any time during the time we hook
// up ringingCall with sipAudioCall. Clean up ringingCall when
// that happens.
ringingCall.reset();
}
return false;
}
}
@ -358,6 +371,11 @@ public class SipPhone extends SipPhoneBase {
}
private class SipCall extends SipCallBase {
void reset() {
connections.clear();
setState(Call.State.IDLE);
}
void switchWith(SipCall that) {
synchronized (SipPhone.class) {
SipCall tmp = new SipCall();