RtpSessionActivity: throw instead of finish when session wasn’t found
This commit is contained in:
parent
63ba21a512
commit
59d1a2982e
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue