Handle dialing a SIP call to self.
Reply BUSY HERE response so server may redirect the call to the voice mailbox. http://b/issue?id=3103072 http://b/issue?id=3109479 Change-Id: I81f5dd59ad87298dd9dda87084538ee460eabba8
This commit is contained in:
@@ -365,6 +365,10 @@ class SipHelper {
|
||||
Response response = mMessageFactory.createResponse(
|
||||
Response.BUSY_HERE, request);
|
||||
|
||||
if (inviteTransaction == null) {
|
||||
inviteTransaction = getServerTransaction(event);
|
||||
}
|
||||
|
||||
if (inviteTransaction.getState() != TransactionState.COMPLETED) {
|
||||
if (DEBUG) Log.d(TAG, "send BUSY HERE: " + response);
|
||||
inviteTransaction.sendResponse(response);
|
||||
|
||||
@@ -430,6 +430,21 @@ public final class SipService extends ISipService.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized boolean callingSelf(SipSessionGroupExt ringingGroup,
|
||||
SipSessionGroup.SipSessionImpl ringingSession) {
|
||||
String callId = ringingSession.getCallId();
|
||||
for (SipSessionGroupExt group : mSipGroups.values()) {
|
||||
if ((group != ringingGroup) && group.containsSession(callId)) {
|
||||
if (DEBUG) Log.d(TAG, "call self: "
|
||||
+ ringingSession.getLocalProfile().getUriString()
|
||||
+ " -> " + group.getLocalProfile().getUriString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private class SipSessionGroupExt extends SipSessionAdapter {
|
||||
private SipSessionGroup mSipGroup;
|
||||
private PendingIntent mIncomingCallPendingIntent;
|
||||
@@ -452,6 +467,10 @@ public final class SipService extends ISipService.Stub {
|
||||
return mSipGroup.getLocalProfile();
|
||||
}
|
||||
|
||||
public boolean containsSession(String callId) {
|
||||
return mSipGroup.containsSession(callId);
|
||||
}
|
||||
|
||||
// network connectivity is tricky because network can be disconnected
|
||||
// at any instant so need to deal with exceptions carefully even when
|
||||
// you think you are connected
|
||||
@@ -551,7 +570,7 @@ public final class SipService extends ISipService.Stub {
|
||||
(SipSessionGroup.SipSessionImpl) s;
|
||||
synchronized (SipService.this) {
|
||||
try {
|
||||
if (!isRegistered()) {
|
||||
if (!isRegistered() || callingSelf(this, session)) {
|
||||
session.endCall();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,6 +231,10 @@ class SipSessionGroup implements SipListener {
|
||||
}
|
||||
}
|
||||
|
||||
synchronized boolean containsSession(String callId) {
|
||||
return mSessionMap.containsKey(callId);
|
||||
}
|
||||
|
||||
private synchronized SipSessionImpl getSipSession(EventObject event) {
|
||||
String key = SipHelper.getCallId(event);
|
||||
SipSessionImpl session = mSessionMap.get(key);
|
||||
@@ -582,6 +586,7 @@ class SipSessionGroup implements SipListener {
|
||||
}
|
||||
|
||||
private void processCommand(EventObject command) throws SipException {
|
||||
if (isLoggable(command)) Log.d(TAG, "process cmd: " + command);
|
||||
if (!process(command)) {
|
||||
onError(SipErrorCode.IN_PROGRESS,
|
||||
"cannot initiate a new transaction to execute: "
|
||||
@@ -1050,6 +1055,13 @@ class SipSessionGroup implements SipListener {
|
||||
mSipHelper.sendCancel(mClientTransaction);
|
||||
startSessionTimer(CANCEL_CALL_TIMER);
|
||||
return true;
|
||||
} else if (isRequestEvent(Request.INVITE, evt)) {
|
||||
// Call self? Send BUSY HERE so server may redirect the call to
|
||||
// voice mailbox.
|
||||
RequestEvent event = (RequestEvent) evt;
|
||||
mSipHelper.sendInviteBusyHere(event,
|
||||
event.getServerTransaction());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1351,6 +1363,10 @@ class SipSessionGroup implements SipListener {
|
||||
return DEBUG;
|
||||
}
|
||||
|
||||
private static boolean isLoggable(EventObject evt) {
|
||||
return isLoggable(null, evt);
|
||||
}
|
||||
|
||||
private static boolean isLoggable(SipSessionImpl s, EventObject evt) {
|
||||
if (!isLoggable(s)) return false;
|
||||
if (evt == null) return false;
|
||||
|
||||
Reference in New Issue
Block a user