ensure that finishConnection succeeds
This commit is contained in:
		
							parent
							
								
									575ada3b27
								
							
						
					
					
						commit
						5e3aab3abe
					
				@ -412,12 +412,14 @@ 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");
 | 
				
			||||||
            finish();
 | 
					            finish();
 | 
				
			||||||
            return true;
 | 
					            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");
 | 
				
			||||||
            finish();
 | 
					            finish();
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
package eu.siacs.conversations.xmpp.jingle;
 | 
					package eu.siacs.conversations.xmpp.jingle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.common.base.MoreObjects;
 | 
				
			||||||
import com.google.common.base.Objects;
 | 
					import com.google.common.base.Objects;
 | 
				
			||||||
import com.google.common.base.Preconditions;
 | 
					import com.google.common.base.Preconditions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -78,14 +79,14 @@ public abstract class AbstractJingleConnection {
 | 
				
			|||||||
            if (this == o) return true;
 | 
					            if (this == o) return true;
 | 
				
			||||||
            if (o == null || getClass() != o.getClass()) return false;
 | 
					            if (o == null || getClass() != o.getClass()) return false;
 | 
				
			||||||
            Id id = (Id) o;
 | 
					            Id id = (Id) o;
 | 
				
			||||||
            return Objects.equal(account.getJid(), id.account.getJid()) &&
 | 
					            return Objects.equal(account.getUuid(), id.account.getUuid()) &&
 | 
				
			||||||
                    Objects.equal(with, id.with) &&
 | 
					                    Objects.equal(with, id.with) &&
 | 
				
			||||||
                    Objects.equal(sessionId, id.sessionId);
 | 
					                    Objects.equal(sessionId, id.sessionId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @Override
 | 
					        @Override
 | 
				
			||||||
        public int hashCode() {
 | 
					        public int hashCode() {
 | 
				
			||||||
            return Objects.hashCode(account.getJid(), with, sessionId);
 | 
					            return Objects.hashCode(account.getUuid(), with, sessionId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @Override
 | 
					        @Override
 | 
				
			||||||
@ -102,6 +103,15 @@ public abstract class AbstractJingleConnection {
 | 
				
			|||||||
        public String getSessionId() {
 | 
					        public String getSessionId() {
 | 
				
			||||||
            return sessionId;
 | 
					            return sessionId;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public String toString() {
 | 
				
			||||||
 | 
					            return MoreObjects.toStringHelper(this)
 | 
				
			||||||
 | 
					                    .add("account", account.getJid())
 | 
				
			||||||
 | 
					                    .add("with", with)
 | 
				
			||||||
 | 
					                    .add("sessionId", sessionId)
 | 
				
			||||||
 | 
					                    .toString();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -134,7 +134,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Optional<RtpSessionProposal> findMatchingSessionProposal(final Account account, final Jid with, final Set<Media> media) {
 | 
					    private Optional<RtpSessionProposal> findMatchingSessionProposal(final Account account, final Jid with, final Set<Media> media) {
 | 
				
			||||||
        synchronized (this.rtpSessionProposals) {
 | 
					        synchronized (this.rtpSessionProposals) {
 | 
				
			||||||
            for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry : this.rtpSessionProposals.entrySet()) {
 | 
					            for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry : this.rtpSessionProposals.entrySet()) {
 | 
				
			||||||
                final RtpSessionProposal proposal = entry.getKey();
 | 
					                final RtpSessionProposal proposal = entry.getKey();
 | 
				
			||||||
@ -446,7 +446,10 @@ public class JingleConnectionManager extends AbstractConnectionManager {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void finishConnection(final AbstractJingleConnection connection) {
 | 
					    void finishConnection(final AbstractJingleConnection connection) {
 | 
				
			||||||
        this.connections.remove(connection.getId());
 | 
					        final AbstractJingleConnection.Id id = connection.getId();
 | 
				
			||||||
 | 
					        if (this.connections.remove(id) == null) {
 | 
				
			||||||
 | 
					            throw new IllegalStateException(String.format("Unable to finish connection with id=%s", id.toString()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void getPrimaryCandidate(final Account account, final boolean initiator, final OnPrimaryCandidateFound listener) {
 | 
					    void getPrimaryCandidate(final Account account, final boolean initiator, final OnPrimaryCandidateFound listener) {
 | 
				
			||||||
@ -667,7 +670,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
 | 
				
			|||||||
        throw e;
 | 
					        throw e;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void endSession(AbstractJingleConnection.Id id, final AbstractJingleConnection.State state) {
 | 
					    void endSession(AbstractJingleConnection.Id id, final AbstractJingleConnection.State state) {
 | 
				
			||||||
        this.endedSessions.put(PersistableSessionId.of(id), state);
 | 
					        this.endedSessions.put(PersistableSessionId.of(id), state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user