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()
|
final WeakReference<JingleRtpConnection> reference = xmppConnectionService.getJingleConnectionManager()
|
||||||
.findJingleRtpConnection(account, with, sessionId);
|
.findJingleRtpConnection(account, with, sessionId);
|
||||||
if (reference == null || reference.get() == null) {
|
if (reference == null || reference.get() == null) {
|
||||||
Log.e(Config.LOGTAG,"failed to initialize activity with running rtp session. session not found");
|
throw new IllegalStateException("failed to initialize activity with running rtp session. session not found");
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
this.rtpConnectionReference = reference;
|
this.rtpConnectionReference = reference;
|
||||||
final RtpEndUserState currentState = requireRtpConnection().getEndUserState();
|
final RtpEndUserState currentState = requireRtpConnection().getEndUserState();
|
||||||
if (currentState == RtpEndUserState.ENDED) {
|
if (currentState == RtpEndUserState.ENDED) {
|
||||||
Log.e(Config.LOGTAG,"failed to initialize activity with running rtp session. session had ended");
|
reference.get().throwStateTransitionException();
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
private final ArrayDeque<IceCandidate> pendingIceCandidates = new ArrayDeque<>();
|
private final ArrayDeque<IceCandidate> pendingIceCandidates = new ArrayDeque<>();
|
||||||
private final Message message;
|
private final Message message;
|
||||||
private State state = State.NULL;
|
private State state = State.NULL;
|
||||||
|
private StateTransitionException stateTransitionException;
|
||||||
private Set<Media> proposedMedia;
|
private Set<Media> proposedMedia;
|
||||||
private RtpContentMap initiatorRtpContentMap;
|
private RtpContentMap initiatorRtpContentMap;
|
||||||
private RtpContentMap responderRtpContentMap;
|
private RtpContentMap responderRtpContentMap;
|
||||||
|
@ -771,6 +772,13 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
xmppConnectionService.sendIqPacket(id.account, jinglePacket.generateResponse(IqPacket.TYPE.RESULT), null);
|
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() {
|
public RtpEndUserState getEndUserState() {
|
||||||
switch (this.state) {
|
switch (this.state) {
|
||||||
case PROPOSED:
|
case PROPOSED:
|
||||||
|
@ -983,6 +991,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
final Collection<State> validTransitions = VALID_TRANSITIONS.get(this.state);
|
final Collection<State> validTransitions = VALID_TRANSITIONS.get(this.state);
|
||||||
if (validTransitions != null && validTransitions.contains(target)) {
|
if (validTransitions != null && validTransitions.contains(target)) {
|
||||||
this.state = target;
|
this.state = target;
|
||||||
|
this.stateTransitionException = new StateTransitionException(target);
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
|
@ -1231,4 +1240,12 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
private interface OnIceServersDiscovered {
|
private interface OnIceServersDiscovered {
|
||||||
void onIceServersDiscovered(List<PeerConnection.IceServer> iceServers);
|
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 New Issue