From 0302eacac1b00b9585cde5a9b86d26e55bf3506a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 10 Apr 2020 10:35:00 +0200 Subject: [PATCH] back button rejects or ends call --- .../siacs/conversations/ui/RtpSessionActivity.java | 10 ++++++++++ .../xmpp/jingle/JingleRtpConnection.java | 12 ++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 1822fef19..47ec38024 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -68,6 +68,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } private void endCall(View view) { + endCall(); + } + + private void endCall() { if (this.rtpConnectionReference == null) { final Intent intent = getIntent(); 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) { final WeakReference reference = xmppConnectionService.getJingleConnectionManager() diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index 52e595b99..b1a2e01e7 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -639,6 +639,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } public void endCall() { + if (isInState(State.PROPOSED) && !isInitiator()) { + rejectCallFromProposed(); + return; + } if (isInState(State.PROCEED)) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ending call while in state PROCEED just means ending the connection"); webRTCWrapper.close(); @@ -651,12 +655,16 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web sendSessionTerminate(Reason.CANCEL); 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(); sendSessionTerminate(Reason.SUCCESS); 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 iceServers) throws WebRTCWrapper.InitializationException {