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.jingle.AbstractJingleConnection;
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.stanzas.JinglePacket;
import eu.siacs.conversations.xmpp.mam.MamReference;
import eu.siacs.conversations.xmpp.pep.Avatar;
import eu.siacs.conversations.xmpp.pep.PublishOptions;
@ -314,7 +312,7 @@ public class XmppConnectionService extends Service {
synchronized (account.inProgressConferencePings) {
account.inProgressConferencePings.clear();
}
mJingleConnectionManager.cancelInTransmission();
mJingleConnectionManager.notifyRebound();
mQuickConversationsService.considerSyncBackground(false);
fetchRosterFromServer(account);

View file

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

View file

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

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) {
final IqPacket response;
if (result) {

View file

@ -65,7 +65,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
State.PROCEED,
State.REJECTED,
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(
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) {
respondOk(jinglePacket);
final JinglePacket.ReasonWrapper wrapper = jinglePacket.getReason();
@ -559,7 +578,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
final JinglePacket jinglePacket = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId);
jinglePacket.setReason(reason, text);
send(jinglePacket);
Log.d(Config.LOGTAG, jinglePacket.toString());
jingleConnectionManager.finishConnection(this);
}
@ -837,14 +855,14 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
return webRTCWrapper.getAudioManager();
}
public void setMicrophoneEnabled(final boolean enabled) {
webRTCWrapper.setMicrophoneEnabled(enabled);
}
public boolean isMicrophoneEnabled() {
return webRTCWrapper.isMicrophoneEnabled();
}
public void setMicrophoneEnabled(final boolean enabled) {
webRTCWrapper.setMicrophoneEnabled(enabled);
}
@Override
public void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices) {
xmppConnectionService.notifyJingleRtpConnectionUpdate(selectedAudioDevice, availableAudioDevices);

View file

@ -50,7 +50,9 @@ public class WebRTCWrapper {
@Override
public void onSignalingChange(PeerConnection.SignalingState 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