Skip to content

Commit 1e11a51

Browse files
author
atsakiridis
committed
Fixed #248: Incoming call doesn't hangup properly. Fixed #247: Incoming P2P calls don't fire in the SDK. Fixed #250: When changing to registrarless no unregister is sent to RestComm
1 parent 9146672 commit 1e11a51

File tree

4 files changed

+53
-23
lines changed

4 files changed

+53
-23
lines changed

restcomm.android.client.sdk/restcomm.android.client.sdk.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id=":restcomm.android.client.sdk" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../Examples/restcomm-helloworld" external.system.id="GRADLE" external.system.module.group="restcomm-helloworld" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id=":restcomm.android.client.sdk" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../Examples/restcomm-olympus" external.system.id="GRADLE" external.system.module.group="restcomm-olympus" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="android-gradle" name="Android-Gradle">
55
<configuration>

restcomm.android.client.sdk/src/main/java/org/mobicents/restcomm/android/client/sdk/RCDevice.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,28 @@ public boolean isDisconnectSoundEnabled() {
508508
*/
509509
public boolean updateParams(HashMap<String, Object> params) {
510510
RCLogger.i(TAG, "updateParams(): " + params.toString());
511-
updateSipProfile(params);
512-
if (reachabilityState != RCDeviceListener.RCConnectivityStatus.RCConnectivityStatusNone) {
513-
DeviceImpl.GetInstance().Register();
514-
return true;
511+
boolean status = false;
512+
513+
if (params.containsKey("pref_proxy_domain") && !params.get("pref_proxy_domain").equals("")) {
514+
// we have a new (non empty) domain, need to register
515+
updateSipProfile(params);
516+
if (reachabilityState != RCDeviceListener.RCConnectivityStatus.RCConnectivityStatusNone) {
517+
DeviceImpl.GetInstance().Register();
518+
status = true;
519+
}
515520
}
516521
else {
517-
return false;
522+
// we have an empty domain
523+
if (!sipProfile.getRemoteEndpoint().equals("")) {
524+
// previously we had a registrar setup, need to unregister (important: we call updateSipProfile afterwards cause if we do no
525+
// unregister will check the SipProfile, find that domain is empty and skip unregistration
526+
DeviceImpl.GetInstance().Unregister();
527+
}
528+
// previously we didn't have a registrar setup, no need to do anything
529+
updateSipProfile(params);
530+
status = true;
518531
}
532+
return status;
519533
}
520534

521535
public void updateSipProfile(HashMap<String, Object> params) {

restcomm.android.client.sdk/src/main/java/org/mobicents/restcomm/android/sipua/impl/DeviceImpl.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,21 @@ public void run() {
332332

333333
}
334334

335-
public void RefreshNetworking()
336-
{
337-
RCLogger.v(TAG, "RefreshNetworking");
335+
public void Unregister() {
336+
RCLogger.v(TAG, "Unregister");
337+
338+
if (sipProfile.getRemoteEndpoint().isEmpty()) {
339+
// registrarless mode, skip unregistration
340+
return;
341+
}
342+
343+
if (registerRefreshHandler != null) {
344+
// we are unregistering, stop future registrations
345+
registerRefreshHandler.removeCallbacksAndMessages(null);
346+
}
338347

339348
try {
340-
this.sipManager.refreshNetworking(registrationExpiry);
349+
this.sipManager.Unregister(null);
341350
} catch (TransactionUnavailableException e) {
342351
if (this.sipuaDeviceListener != null) {
343352
// notify our listener that we are connecting
@@ -351,21 +360,12 @@ public void RefreshNetworking()
351360
}
352361
}
353362

354-
public void Unregister() {
355-
RCLogger.v(TAG, "Unregister");
356-
357-
if (sipProfile.getRemoteEndpoint().isEmpty()) {
358-
// registrarless mode, skip unregistration
359-
return;
360-
}
361-
362-
if (registerRefreshHandler != null) {
363-
// we are unregistering, stop future registrations
364-
registerRefreshHandler.removeCallbacksAndMessages(null);
365-
}
363+
public void RefreshNetworking()
364+
{
365+
RCLogger.v(TAG, "RefreshNetworking");
366366

367367
try {
368-
this.sipManager.Unregister(null);
368+
this.sipManager.refreshNetworking(registrationExpiry);
369369
} catch (TransactionUnavailableException e) {
370370
if (this.sipuaDeviceListener != null) {
371371
// notify our listener that we are connecting

restcomm.android.client.sdk/src/main/java/org/mobicents/restcomm/android/sipua/impl/SipManager.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import android.javax.sip.header.ContactHeader;
6767
import android.javax.sip.header.ContentTypeHeader;
6868
import android.javax.sip.header.HeaderFactory;
69+
import android.javax.sip.header.RouteHeader;
6970
import android.javax.sip.header.ToHeader;
7071
import android.javax.sip.header.UserAgentHeader;
7172
import android.javax.sip.header.ViaHeader;
@@ -1020,6 +1021,7 @@ private void incomingInvite(RequestEvent requestEvent,
10201021
&& sipManagerState != SipManagerState.READY
10211022
&& sipManagerState != SipManagerState.INCOMING
10221023
) {
1024+
RCLogger.i(TAG, "incomingInvite(): invalid state: " + sipManagerState + " -bailing");
10231025
// sendDecline(requestEvent.getRequest());// Already in a call
10241026
return;
10251027
}
@@ -1035,6 +1037,7 @@ private void incomingInvite(RequestEvent requestEvent,
10351037

10361038
}
10371039
if (st == null) {
1040+
RCLogger.i(TAG, "incomingInvite(): server transaction still null");
10381041
return;
10391042
}
10401043
dialog = st.getDialog();
@@ -1162,9 +1165,22 @@ private void sendByeClient(Transaction transaction) {
11621165
Request byeRequest = null;
11631166
try {
11641167
byeRequest = dialog.createRequest(Request.BYE);
1168+
if (!getSipProfile().getRemoteEndpoint().isEmpty()) {
1169+
// we only need this for non-registrarless calls since the problem is only for incoming calls,
1170+
// and when working in registrarless mode there are no incoming calls
1171+
SipURI routeUri = (SipURI) addressFactory.createURI(getSipProfile().getRemoteEndpoint());
1172+
routeUri.setLrParam();
1173+
Address routeAddress = addressFactory.createAddress(routeUri);
1174+
RouteHeader routeHeader = headerFactory.createRouteHeader(routeAddress);
1175+
byeRequest.addFirst(routeHeader);
1176+
}
1177+
11651178
} catch (SipException e) {
11661179
// TODO Auto-generated catch block
11671180
e.printStackTrace();
1181+
} catch (ParseException e) {
1182+
// TODO Auto-generated catch block
1183+
e.printStackTrace();
11681184
}
11691185

11701186
final Request r = byeRequest;

0 commit comments

Comments
 (0)