back button rejects or ends call

This commit is contained in:
Daniel Gultsch 2020-04-10 10:35:00 +02:00
parent f5c4de8770
commit 0302eacac1
2 changed files with 20 additions and 2 deletions

View File

@ -68,6 +68,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
} }
private void endCall(View view) { private void endCall(View view) {
endCall();
}
private void endCall() {
if (this.rtpConnectionReference == null) { if (this.rtpConnectionReference == null) {
final Intent intent = getIntent(); final Intent intent = getIntent();
final Account account = extractAccount(intent); final Account account = extractAccount(intent);
@ -165,6 +169,12 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
} }
} }
@Override
public void onBackPressed() {
endCall();
super.onBackPressed();
}
private void initializeActivityWithRunningRapSession(final Account account, Jid with, String sessionId) { private void initializeActivityWithRunningRapSession(final Account account, Jid with, String sessionId) {
final WeakReference<JingleRtpConnection> reference = xmppConnectionService.getJingleConnectionManager() final WeakReference<JingleRtpConnection> reference = xmppConnectionService.getJingleConnectionManager()

View File

@ -639,6 +639,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
} }
public void endCall() { public void endCall() {
if (isInState(State.PROPOSED) && !isInitiator()) {
rejectCallFromProposed();
return;
}
if (isInState(State.PROCEED)) { if (isInState(State.PROCEED)) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ending call while in state PROCEED just means ending the connection"); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ending call while in state PROCEED just means ending the connection");
webRTCWrapper.close(); webRTCWrapper.close();
@ -651,12 +655,16 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
sendSessionTerminate(Reason.CANCEL); sendSessionTerminate(Reason.CANCEL);
return; return;
} }
if (isInState(State.SESSION_INITIALIZED, State.SESSION_INITIALIZED_PRE_APPROVED, State.SESSION_ACCEPTED)) { if (isInState(State.SESSION_INITIALIZED)) {
rejectCallFromSessionInitiate();
return;
}
if (isInState(State.SESSION_INITIALIZED_PRE_APPROVED, State.SESSION_ACCEPTED)) {
webRTCWrapper.close(); webRTCWrapper.close();
sendSessionTerminate(Reason.SUCCESS); sendSessionTerminate(Reason.SUCCESS);
return; return;
} }
throw new IllegalStateException("called 'endCall' while in state " + this.state); throw new IllegalStateException("called 'endCall' while in state " + this.state + ". isInitiator=" + isInitiator());
} }
private void setupWebRTC(final List<PeerConnection.IceServer> iceServers) throws WebRTCWrapper.InitializationException { private void setupWebRTC(final List<PeerConnection.IceServer> iceServers) throws WebRTCWrapper.InitializationException {