Commit 6f283ef3 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

call service: synchronize state change

Change-Id: I50426174a6441aa53cb042890ae42233bdc73d8a
parent 17d34dc8
......@@ -453,23 +453,27 @@ public class CallService {
}
public void removeCallForId(String callId) {
currentCalls.remove(callId);
currentConferences.remove(callId);
synchronized (currentCalls) {
currentCalls.remove(callId);
currentConferences.remove(callId);
}
}
private SipCall addCall(String accountId, String callId, String from, SipCall.Direction direction) {
SipCall call = currentCalls.get(callId);
if (call == null) {
Account account = mAccountService.getAccount(accountId);
Uri fromUri = new Uri(from);
Conversation conversation = account.getByUri(fromUri);
CallContact contact = mContactService.findContact(account, fromUri);
call = new SipCall(callId, new Uri(from).getUri(), accountId, conversation, contact, direction);
currentCalls.put(callId, call);
} else {
Log.w(TAG, "Call already existed ! " + callId + " " + from);
synchronized (currentCalls) {
SipCall call = currentCalls.get(callId);
if (call == null) {
Account account = mAccountService.getAccount(accountId);
Uri fromUri = new Uri(from);
Conversation conversation = account.getByUri(fromUri);
CallContact contact = mContactService.findContact(account, fromUri);
call = new SipCall(callId, new Uri(from).getUri(), accountId, conversation, contact, direction);
currentCalls.put(callId, call);
} else {
Log.w(TAG, "Call already existed ! " + callId + " " + from);
}
return call;
}
return call;
}
private Conference addConference(SipCall call) {
......@@ -537,13 +541,15 @@ public class CallService {
void callStateChanged(String callId, String newState, int detailCode) {
Log.d(TAG, "call state changed: " + callId + ", " + newState + ", " + detailCode);
try {
SipCall call = parseCallState(callId, newState);
if (call != null) {
callSubject.onNext(call);
if (call.getCallStatus() == SipCall.CallStatus.OVER) {
currentCalls.remove(call.getDaemonIdString());
currentConferences.remove(call.getDaemonIdString());
updateConnectionCount();
synchronized (currentCalls) {
SipCall call = parseCallState(callId, newState);
if (call != null) {
callSubject.onNext(call);
if (call.getCallStatus() == SipCall.CallStatus.OVER) {
currentCalls.remove(call.getDaemonIdString());
currentConferences.remove(call.getDaemonIdString());
updateConnectionCount();
}
}
}
} catch (Exception e) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment