Change summary
src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java | 8
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java | 17
2 files changed, 20 insertions(+), 5 deletions(-)
Detailed changes
@@ -412,14 +412,12 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
final WeakReference<JingleRtpConnection> reference = xmppConnectionService.getJingleConnectionManager()
.findJingleRtpConnection(account, with, sessionId);
if (reference == null || reference.get() == null) {
- Log.e(Config.LOGTAG,"failed to initialize activity with running rtp session. session not found");
- finish();
- return true;
+ throw new IllegalStateException("failed to initialize activity with running rtp session. session not found");
}
this.rtpConnectionReference = reference;
final RtpEndUserState currentState = requireRtpConnection().getEndUserState();
if (currentState == RtpEndUserState.ENDED) {
- Log.e(Config.LOGTAG,"failed to initialize activity with running rtp session. session had ended");
+ reference.get().throwStateTransitionException();
finish();
return true;
}
@@ -795,7 +793,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
try {
videoTrack.addSink(surfaceViewRenderer);
} catch (final IllegalStateException e) {
- Log.e(Config.LOGTAG,"possible race condition on trying to display video track. ignoring",e);
+ Log.e(Config.LOGTAG, "possible race condition on trying to display video track. ignoring", e);
}
}
@@ -123,6 +123,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
private final ArrayDeque<IceCandidate> pendingIceCandidates = new ArrayDeque<>();
private final Message message;
private State state = State.NULL;
+ private StateTransitionException stateTransitionException;
private Set<Media> proposedMedia;
private RtpContentMap initiatorRtpContentMap;
private RtpContentMap responderRtpContentMap;
@@ -771,6 +772,13 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
xmppConnectionService.sendIqPacket(id.account, jinglePacket.generateResponse(IqPacket.TYPE.RESULT), null);
}
+ public void throwStateTransitionException() {
+ final StateTransitionException exception = this.stateTransitionException;
+ if (exception != null) {
+ throw new IllegalStateException(String.format("Transition to %s did not call finish", exception.state), exception);
+ }
+ }
+
public RtpEndUserState getEndUserState() {
switch (this.state) {
case PROPOSED:
@@ -983,6 +991,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
final Collection<State> validTransitions = VALID_TRANSITIONS.get(this.state);
if (validTransitions != null && validTransitions.contains(target)) {
this.state = target;
+ this.stateTransitionException = new StateTransitionException(target);
if (runnable != null) {
runnable.run();
}
@@ -1231,4 +1240,12 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
private interface OnIceServersDiscovered {
void onIceServersDiscovered(List<PeerConnection.IceServer> iceServers);
}
+
+ private static class StateTransitionException extends Exception {
+ private final State state;
+
+ private StateTransitionException(final State state) {
+ this.state = state;
+ }
+ }
}