terminate jingle call when regular call starts
This commit is contained in:
parent
91e94db747
commit
d158eeaf72
|
@ -268,7 +268,10 @@ public class XmppConnectionService extends Service {
|
|||
private final PhoneStateListener phoneStateListener = new PhoneStateListener() {
|
||||
@Override
|
||||
public void onCallStateChanged(final int state, final String phoneNumber) {
|
||||
isPhoneInCall.set(state != 0);
|
||||
isPhoneInCall.set(state != TelephonyManager.CALL_STATE_IDLE);
|
||||
if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
|
||||
mJingleConnectionManager.notifyPhoneCallStarted();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -137,6 +138,18 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void notifyPhoneCallStarted() {
|
||||
for (AbstractJingleConnection connection : connections.values()) {
|
||||
if (connection instanceof JingleRtpConnection) {
|
||||
final JingleRtpConnection rtpConnection = (JingleRtpConnection) connection;
|
||||
if (rtpConnection.isTerminated()) {
|
||||
continue;
|
||||
}
|
||||
rtpConnection.notifyPhoneCall();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<RtpSessionProposal> findMatchingSessionProposal(final Account account, final Jid with, final Set<Media> media) {
|
||||
synchronized (this.rtpSessionProposals) {
|
||||
for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry : this.rtpSessionProposals.entrySet()) {
|
||||
|
|
|
@ -901,6 +901,16 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void notifyPhoneCall() {
|
||||
Log.d(Config.LOGTAG, "a phone call has just been started. killing jingle rtp connections");
|
||||
if (Arrays.asList(State.PROPOSED, State.SESSION_INITIALIZED).contains(this.state)) {
|
||||
rejectCall();
|
||||
} else {
|
||||
endCall();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void rejectCall() {
|
||||
if (isTerminated()) {
|
||||
Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": received rejectCall() when session has already been terminated. nothing to do");
|
||||
|
|
Loading…
Reference in a new issue