recover from pre-jingle connection states (discover etc) into full fledged jingle connection

fixes #3847
This commit is contained in:
Daniel Gultsch 2020-08-01 09:50:51 +02:00
parent f22e33e3ea
commit 1ae7d6be16
3 changed files with 42 additions and 2 deletions

View file

@ -371,15 +371,23 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
} else if (Intent.ACTION_VIEW.equals(action)) {
final String extraLastState = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE);
if (extraLastState != null) {
final RtpEndUserState state = extraLastState == null ? null : RtpEndUserState.valueOf(extraLastState);
if (state != null) {
Log.d(Config.LOGTAG, "restored last state from intent extra");
RtpEndUserState state = RtpEndUserState.valueOf(extraLastState);
updateButtonConfiguration(state);
updateStateDisplay(state);
updateProfilePicture(state);
invalidateOptionsMenu();
}
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
if (xmppConnectionService.getJingleConnectionManager().fireJingleRtpConnectionStateUpdates()) {
return;
}
if (END_CARD.contains(state) || xmppConnectionService.getJingleConnectionManager().hasMatchingProposal(account, with)) {
return;
}
Log.d(Config.LOGTAG, "restored state (" + state + ") was not an end card. finishing");
finish();
}
}

View file

@ -456,6 +456,21 @@ public class JingleConnectionManager extends AbstractConnectionManager {
}
}
public boolean fireJingleRtpConnectionStateUpdates() {
boolean firedUpdates = false;
for (final AbstractJingleConnection connection : this.connections.values()) {
if (connection instanceof JingleRtpConnection) {
final JingleRtpConnection jingleRtpConnection = (JingleRtpConnection) connection;
if (jingleRtpConnection.isTerminated()) {
continue;
}
jingleRtpConnection.fireStateUpdate();
firedUpdates = true;
}
}
return firedUpdates;
}
void getPrimaryCandidate(final Account account, final boolean initiator, final OnPrimaryCandidateFound listener) {
if (Config.DISABLE_PROXY_LOOKUP) {
listener.onPrimaryCandidateFound(false, null);
@ -576,6 +591,18 @@ public class JingleConnectionManager extends AbstractConnectionManager {
}
}
public boolean hasMatchingProposal(final Account account, final Jid with) {
synchronized (this.rtpSessionProposals) {
for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry : this.rtpSessionProposals.entrySet()) {
final RtpSessionProposal proposal = entry.getKey();
if (proposal.account == account && with.asBareJid().equals(proposal.with)) {
return true;
}
}
}
return false;
}
public void deliverIbbPacket(Account account, IqPacket packet) {
final String sid;
final Element payload;

View file

@ -1263,6 +1263,11 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
this.proposedMedia = media;
}
public void fireStateUpdate() {
final RtpEndUserState endUserState = getEndUserState();
xmppConnectionService.notifyJingleRtpConnectionUpdate(id.account, id.with, id.sessionId, endUserState);
}
private interface OnIceServersDiscovered {
void onIceServersDiscovered(List<PeerConnection.IceServer> iceServers);
}