diff options
author | Hung-ying Tyan <tyanh@google.com> | 2010-10-18 21:04:18 +0800 |
---|---|---|
committer | jsh <jsh@google.com> | 2010-10-19 14:00:11 -0700 |
commit | 0a6e717fb6846f66b8dc853e079f2166307bfc60 (patch) | |
tree | 61bb1736d824e1e36b6c0914eba120276f316dbf /voip/java/com/android/server/sip | |
parent | 59993d9bc589089e6be55371c6536a42afe21a64 (diff) | |
download | frameworks_base-0a6e717fb6846f66b8dc853e079f2166307bfc60.zip frameworks_base-0a6e717fb6846f66b8dc853e079f2166307bfc60.tar.gz frameworks_base-0a6e717fb6846f66b8dc853e079f2166307bfc60.tar.bz2 |
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
Diffstat (limited to 'voip/java/com/android/server/sip')
-rw-r--r-- | voip/java/com/android/server/sip/SipHelper.java | 4 | ||||
-rw-r--r-- | voip/java/com/android/server/sip/SipService.java | 21 | ||||
-rw-r--r-- | voip/java/com/android/server/sip/SipSessionGroup.java | 16 |
3 files changed, 40 insertions, 1 deletions
diff --git a/voip/java/com/android/server/sip/SipHelper.java b/voip/java/com/android/server/sip/SipHelper.java index 2514262..13e6f14 100644 --- a/voip/java/com/android/server/sip/SipHelper.java +++ b/voip/java/com/android/server/sip/SipHelper.java @@ -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); diff --git a/voip/java/com/android/server/sip/SipService.java b/voip/java/com/android/server/sip/SipService.java index a6f0d88..2a35fb0 100644 --- a/voip/java/com/android/server/sip/SipService.java +++ b/voip/java/com/android/server/sip/SipService.java @@ -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; } diff --git a/voip/java/com/android/server/sip/SipSessionGroup.java b/voip/java/com/android/server/sip/SipSessionGroup.java index bb246a6..50ce7dc 100644 --- a/voip/java/com/android/server/sip/SipSessionGroup.java +++ b/voip/java/com/android/server/sip/SipSessionGroup.java @@ -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; |