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.
master
Curt Brune 2019-11-05 21:44:32 -08:00 committed by Alan Evans
parent 7348237862
commit 17a1fe97ca
1 changed files with 23 additions and 6 deletions

View File

@ -464,7 +464,7 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
} catch (CallException e) {
Log.w(TAG, e);
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) {
Log.w(TAG, e);
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_REMOTE_RECIPIENT, recipient.getId());
handleCallConnected(intent);
activateCallMedia();
} catch (CallException e) {
Log.w(TAG, e);
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
terminate();
hangupAndTerminate();
}
activateCallMedia();
}
private void handleDenyCall(Intent intent) {
@ -770,7 +770,8 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
} catch (CallException e) {
Log.w(TAG, e);
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);
break;
}
terminate();
hangupAndTerminate();
}
@ -934,6 +935,22 @@ public class WebRtcCallService extends Service implements CallConnection.Observe
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() {
Log.i(TAG, "terminate()");