mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-26 12:07:50 +00:00
Send hangup message when terminating on call errors.
When errors occur during a call, attempt to send the remote peer a hangup message before terminating the call. This allows the remote peer to shutdown their side of the call in a timely manner.
This commit is contained in:
@@ -464,7 +464,7 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
|
|||||||
} catch (CallException e) {
|
} catch (CallException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
||||||
terminate();
|
hangupAndTerminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
|
|||||||
} catch (CallException e) {
|
} catch (CallException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
||||||
terminate();
|
hangupAndTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -672,13 +672,13 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
|
|||||||
intent.putExtra(EXTRA_CALL_ID, callId);
|
intent.putExtra(EXTRA_CALL_ID, callId);
|
||||||
intent.putExtra(EXTRA_REMOTE_RECIPIENT, recipient.getId());
|
intent.putExtra(EXTRA_REMOTE_RECIPIENT, recipient.getId());
|
||||||
handleCallConnected(intent);
|
handleCallConnected(intent);
|
||||||
|
activateCallMedia();
|
||||||
} catch (CallException e) {
|
} catch (CallException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
||||||
terminate();
|
hangupAndTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
activateCallMedia();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDenyCall(Intent intent) {
|
private void handleDenyCall(Intent intent) {
|
||||||
@@ -770,7 +770,8 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
|
|||||||
} catch (CallException e) {
|
} catch (CallException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
||||||
terminate();
|
hangupAndTerminate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -890,7 +891,7 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
|
|||||||
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
terminate();
|
hangupAndTerminate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,6 +935,22 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
|
|||||||
CallNotificationBuilder.getCallInProgressNotification(this, type, recipient));
|
CallNotificationBuilder.getCallInProgressNotification(this, type, recipient));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void hangupAndTerminate() {
|
||||||
|
if (callConnection != null && callId != null) {
|
||||||
|
accountManager.cancelInFlightRequests();
|
||||||
|
messageSender.cancelInFlightRequests();
|
||||||
|
|
||||||
|
try {
|
||||||
|
callConnection.hangUp();
|
||||||
|
} catch (CallException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
terminate();
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void terminate() {
|
private synchronized void terminate() {
|
||||||
Log.i(TAG, "terminate()");
|
Log.i(TAG, "terminate()");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user