cancle ongoing jingle sessions on xmpp rebind

This commit is contained in:
Daniel Gultsch 2020-04-13 18:30:12 +02:00
parent 493ca68464
commit e16e0d895e
6 changed files with 42 additions and 17 deletions

View File

@ -145,9 +145,7 @@ import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection; import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager; import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager;
import eu.siacs.conversations.xmpp.jingle.OnJinglePacketReceived;
import eu.siacs.conversations.xmpp.jingle.RtpEndUserState; import eu.siacs.conversations.xmpp.jingle.RtpEndUserState;
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
import eu.siacs.conversations.xmpp.mam.MamReference; import eu.siacs.conversations.xmpp.mam.MamReference;
import eu.siacs.conversations.xmpp.pep.Avatar; import eu.siacs.conversations.xmpp.pep.Avatar;
import eu.siacs.conversations.xmpp.pep.PublishOptions; import eu.siacs.conversations.xmpp.pep.PublishOptions;
@ -314,7 +312,7 @@ public class XmppConnectionService extends Service {
synchronized (account.inProgressConferencePings) { synchronized (account.inProgressConferencePings) {
account.inProgressConferencePings.clear(); account.inProgressConferencePings.clear();
} }
mJingleConnectionManager.cancelInTransmission(); mJingleConnectionManager.notifyRebound();
mQuickConversationsService.considerSyncBackground(false); mQuickConversationsService.considerSyncBackground(false);
fetchRosterFromServer(account); fetchRosterFromServer(account);

View File

@ -36,6 +36,8 @@ public abstract class AbstractJingleConnection {
return id; return id;
} }
abstract void notifyRebound();
public static class Id { public static class Id {
public final Account account; public final Account account;

View File

@ -376,11 +376,9 @@ public class JingleConnectionManager extends AbstractConnectionManager {
account.getXmppConnection().sendIqPacket(packet.generateResponse(IqPacket.TYPE.ERROR), null); account.getXmppConnection().sendIqPacket(packet.generateResponse(IqPacket.TYPE.ERROR), null);
} }
public void cancelInTransmission() { public void notifyRebound() {
for (AbstractJingleConnection connection : this.connections.values()) { for (final AbstractJingleConnection connection : this.connections.values()) {
/*if (connection.getJingleStatus() == JingleFileTransferConnection.JINGLE_STATUS_TRANSMITTING) { connection.notifyRebound();
connection.abort("connectivity-error");
}*/
} }
} }

View File

@ -293,6 +293,13 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
} }
} }
@Override
void notifyRebound() {
if (getJingleStatus() == JINGLE_STATUS_TRANSMITTING) {
abort(Reason.CONNECTIVITY_ERROR);
}
}
private void respondToIq(final IqPacket packet, final boolean result) { private void respondToIq(final IqPacket packet, final boolean result) {
final IqPacket response; final IqPacket response;
if (result) { if (result) {

View File

@ -65,7 +65,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
State.PROCEED, State.PROCEED,
State.REJECTED, State.REJECTED,
State.RETRACTED, State.RETRACTED,
State.TERMINATED_APPLICATION_FAILURE State.TERMINATED_APPLICATION_FAILURE,
State.TERMINATED_CONNECTIVITY_ERROR //only used when the xmpp connection rebinds
)); ));
transitionBuilder.put(State.PROCEED, ImmutableList.of( transitionBuilder.put(State.PROCEED, ImmutableList.of(
State.SESSION_INITIALIZED_PRE_APPROVED, State.SESSION_INITIALIZED_PRE_APPROVED,
@ -164,6 +165,24 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
} }
} }
@Override
void notifyRebound() {
if (TERMINATED.contains(this.state)) {
return;
}
webRTCWrapper.close();
if (!isInitiator() && isInState(State.PROPOSED,State.SESSION_INITIALIZED)) {
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
}
if (isInState(State.SESSION_INITIALIZED, State.SESSION_INITIALIZED_PRE_APPROVED, State.SESSION_ACCEPTED)) {
//we might have already changed resources (full jid) at this point; so this might not even reach the other party
sendSessionTerminate(Reason.CONNECTIVITY_ERROR);
} else {
transitionOrThrow(State.TERMINATED_CONNECTIVITY_ERROR);
jingleConnectionManager.finishConnection(this);
}
}
private void receiveSessionTerminate(final JinglePacket jinglePacket) { private void receiveSessionTerminate(final JinglePacket jinglePacket) {
respondOk(jinglePacket); respondOk(jinglePacket);
final JinglePacket.ReasonWrapper wrapper = jinglePacket.getReason(); final JinglePacket.ReasonWrapper wrapper = jinglePacket.getReason();
@ -496,7 +515,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
if (from.equals(id.with)) { if (from.equals(id.with)) {
if (transition(State.RETRACTED)) { if (transition(State.RETRACTED)) {
xmppConnectionService.getNotificationService().cancelIncomingCallNotification(); xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": session with " + id.with + " has been retracted (serverMsgId="+serverMsgId+")"); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": session with " + id.with + " has been retracted (serverMsgId=" + serverMsgId + ")");
if (serverMsgId != null) { if (serverMsgId != null) {
this.message.setServerMsgId(serverMsgId); this.message.setServerMsgId(serverMsgId);
} }
@ -559,7 +578,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
final JinglePacket jinglePacket = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId); final JinglePacket jinglePacket = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId);
jinglePacket.setReason(reason, text); jinglePacket.setReason(reason, text);
send(jinglePacket); send(jinglePacket);
Log.d(Config.LOGTAG, jinglePacket.toString());
jingleConnectionManager.finishConnection(this); jingleConnectionManager.finishConnection(this);
} }
@ -837,14 +855,14 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
return webRTCWrapper.getAudioManager(); return webRTCWrapper.getAudioManager();
} }
public void setMicrophoneEnabled(final boolean enabled) {
webRTCWrapper.setMicrophoneEnabled(enabled);
}
public boolean isMicrophoneEnabled() { public boolean isMicrophoneEnabled() {
return webRTCWrapper.isMicrophoneEnabled(); return webRTCWrapper.isMicrophoneEnabled();
} }
public void setMicrophoneEnabled(final boolean enabled) {
webRTCWrapper.setMicrophoneEnabled(enabled);
}
@Override @Override
public void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices) { public void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices) {
xmppConnectionService.notifyJingleRtpConnectionUpdate(selectedAudioDevice, availableAudioDevices); xmppConnectionService.notifyJingleRtpConnectionUpdate(selectedAudioDevice, availableAudioDevices);
@ -934,7 +952,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
} }
private void writeLogMessageMissed() { private void writeLogMessageMissed() {
this.message.setBody(new RtpSessionStatus(false,0).toString()); this.message.setBody(new RtpSessionStatus(false, 0).toString());
this.writeMessage(); this.writeMessage();
} }

View File

@ -50,7 +50,9 @@ public class WebRTCWrapper {
@Override @Override
public void onSignalingChange(PeerConnection.SignalingState signalingState) { public void onSignalingChange(PeerConnection.SignalingState signalingState) {
Log.d(Config.LOGTAG, "onSignalingChange(" + signalingState + ")"); Log.d(Config.LOGTAG, "onSignalingChange(" + signalingState + ")");
//this is called after removeTrack or addTrack
//and should then trigger a content-add or content-remove or something
//https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/removeTrack
} }
@Override @Override