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) {
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<JingleRtpConnection> reference = xmppConnectionService.getJingleConnectionManager()

View file

@ -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<PeerConnection.IceServer> iceServers) throws WebRTCWrapper.InitializationException {