add optional strict offline checking for calls
This commit is contained in:
parent
d4225fcf32
commit
1090b2edd3
|
@ -121,6 +121,8 @@ public final class Config {
|
||||||
false; // disables STUN/TURN and Proxy65 look up (useful to debug IBB fallback)
|
false; // disables STUN/TURN and Proxy65 look up (useful to debug IBB fallback)
|
||||||
public static final boolean USE_DIRECT_JINGLE_CANDIDATES = true;
|
public static final boolean USE_DIRECT_JINGLE_CANDIDATES = true;
|
||||||
public static final boolean USE_JINGLE_MESSAGE_INIT = true;
|
public static final boolean USE_JINGLE_MESSAGE_INIT = true;
|
||||||
|
|
||||||
|
public static final boolean JINGLE_MESSAGE_INIT_STRICT_OFFLINE_CHECK = false;
|
||||||
public static final boolean DISABLE_HTTP_UPLOAD = false;
|
public static final boolean DISABLE_HTTP_UPLOAD = false;
|
||||||
public static final boolean EXTENDED_SM_LOGGING = false; // log stanza counts
|
public static final boolean EXTENDED_SM_LOGGING = false; // log stanza counts
|
||||||
public static final boolean BACKGROUND_STANZA_LOGGING =
|
public static final boolean BACKGROUND_STANZA_LOGGING =
|
||||||
|
|
|
@ -83,6 +83,12 @@ public class Presences {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
synchronized (this.presences) {
|
||||||
|
return this.presences.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String[] toResourceArray() {
|
public String[] toResourceArray() {
|
||||||
synchronized (this.presences) {
|
synchronized (this.presences) {
|
||||||
final String[] presencesArray = new String[presences.size()];
|
final String[] presencesArray = new String[presences.size()];
|
||||||
|
|
|
@ -303,6 +303,7 @@ public class CallIntegration extends Connection {
|
||||||
@Override
|
@Override
|
||||||
public void onStateChanged(final int state) {
|
public void onStateChanged(final int state) {
|
||||||
Log.d(Config.LOGTAG, "onStateChanged(" + state + ")");
|
Log.d(Config.LOGTAG, "onStateChanged(" + state + ")");
|
||||||
|
// TODO devices before selfManaged() will likely have to play their own ringback sound
|
||||||
if (state == STATE_ACTIVE) {
|
if (state == STATE_ACTIVE) {
|
||||||
playConnectedSound();
|
playConnectedSound();
|
||||||
} else if (state == STATE_DISCONNECTED) {
|
} else if (state == STATE_DISCONNECTED) {
|
||||||
|
|
|
@ -97,15 +97,26 @@ public class CallIntegrationConnectionService extends ConnectionService {
|
||||||
intent.putExtra(RtpSessionActivity.EXTRA_WITH, with.toEscapedString());
|
intent.putExtra(RtpSessionActivity.EXTRA_WITH, with.toEscapedString());
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
final CallIntegration callIntegration;
|
final Connection callIntegration;
|
||||||
if (with.isBareJid()) {
|
if (with.isBareJid()) {
|
||||||
final var proposal =
|
final var contact = account.getRoster().getContact(with);
|
||||||
service.getJingleConnectionManager()
|
if (Config.JINGLE_MESSAGE_INIT_STRICT_OFFLINE_CHECK
|
||||||
.proposeJingleRtpSession(account, with, media);
|
&& contact.getPresences().isEmpty()) {
|
||||||
|
intent.putExtra(
|
||||||
intent.putExtra(
|
RtpSessionActivity.EXTRA_LAST_REPORTED_STATE,
|
||||||
RtpSessionActivity.EXTRA_LAST_REPORTED_STATE,
|
RtpEndUserState.CONTACT_OFFLINE.toString());
|
||||||
RtpEndUserState.FINDING_DEVICE.toString());
|
callIntegration =
|
||||||
|
Connection.createFailedConnection(
|
||||||
|
new DisconnectCause(DisconnectCause.ERROR, "contact is offline"));
|
||||||
|
} else {
|
||||||
|
final var proposal =
|
||||||
|
service.getJingleConnectionManager()
|
||||||
|
.proposeJingleRtpSession(account, with, media);
|
||||||
|
intent.putExtra(
|
||||||
|
RtpSessionActivity.EXTRA_LAST_REPORTED_STATE,
|
||||||
|
RtpEndUserState.FINDING_DEVICE.toString());
|
||||||
|
callIntegration = proposal.getCallIntegration();
|
||||||
|
}
|
||||||
if (Media.audioOnly(media)) {
|
if (Media.audioOnly(media)) {
|
||||||
intent.putExtra(
|
intent.putExtra(
|
||||||
RtpSessionActivity.EXTRA_LAST_ACTION,
|
RtpSessionActivity.EXTRA_LAST_ACTION,
|
||||||
|
@ -115,7 +126,6 @@ public class CallIntegrationConnectionService extends ConnectionService {
|
||||||
RtpSessionActivity.EXTRA_LAST_ACTION,
|
RtpSessionActivity.EXTRA_LAST_ACTION,
|
||||||
RtpSessionActivity.ACTION_MAKE_VIDEO_CALL);
|
RtpSessionActivity.ACTION_MAKE_VIDEO_CALL);
|
||||||
}
|
}
|
||||||
callIntegration = proposal.getCallIntegration();
|
|
||||||
} else {
|
} else {
|
||||||
final JingleRtpConnection jingleRtpConnection =
|
final JingleRtpConnection jingleRtpConnection =
|
||||||
service.getJingleConnectionManager().initializeRtpSession(account, with, media);
|
service.getJingleConnectionManager().initializeRtpSession(account, with, media);
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class RtpSessionActivity extends XmppActivity
|
||||||
RtpEndUserState.APPLICATION_ERROR,
|
RtpEndUserState.APPLICATION_ERROR,
|
||||||
RtpEndUserState.SECURITY_ERROR,
|
RtpEndUserState.SECURITY_ERROR,
|
||||||
RtpEndUserState.DECLINED_OR_BUSY,
|
RtpEndUserState.DECLINED_OR_BUSY,
|
||||||
|
RtpEndUserState.CONTACT_OFFLINE,
|
||||||
RtpEndUserState.CONNECTIVITY_ERROR,
|
RtpEndUserState.CONNECTIVITY_ERROR,
|
||||||
RtpEndUserState.CONNECTIVITY_LOST_ERROR,
|
RtpEndUserState.CONNECTIVITY_LOST_ERROR,
|
||||||
RtpEndUserState.RETRACTED);
|
RtpEndUserState.RETRACTED);
|
||||||
|
@ -881,6 +882,7 @@ public class RtpSessionActivity extends XmppActivity
|
||||||
case FINDING_DEVICE -> setTitle(R.string.rtp_state_finding_device);
|
case FINDING_DEVICE -> setTitle(R.string.rtp_state_finding_device);
|
||||||
case RINGING -> setTitle(R.string.rtp_state_ringing);
|
case RINGING -> setTitle(R.string.rtp_state_ringing);
|
||||||
case DECLINED_OR_BUSY -> setTitle(R.string.rtp_state_declined_or_busy);
|
case DECLINED_OR_BUSY -> setTitle(R.string.rtp_state_declined_or_busy);
|
||||||
|
case CONTACT_OFFLINE -> setTitle(R.string.rtp_state_contact_offline);
|
||||||
case CONNECTIVITY_ERROR -> setTitle(R.string.rtp_state_connectivity_error);
|
case CONNECTIVITY_ERROR -> setTitle(R.string.rtp_state_connectivity_error);
|
||||||
case CONNECTIVITY_LOST_ERROR -> setTitle(R.string.rtp_state_connectivity_lost_error);
|
case CONNECTIVITY_LOST_ERROR -> setTitle(R.string.rtp_state_connectivity_lost_error);
|
||||||
case RETRACTED -> setTitle(R.string.rtp_state_retracted);
|
case RETRACTED -> setTitle(R.string.rtp_state_retracted);
|
||||||
|
@ -974,7 +976,8 @@ public class RtpSessionActivity extends XmppActivity
|
||||||
this.binding.acceptCall.setOnClickListener((v -> acceptContentAdd(contentAddition)));
|
this.binding.acceptCall.setOnClickListener((v -> acceptContentAdd(contentAddition)));
|
||||||
this.binding.acceptCall.setImageResource(R.drawable.ic_baseline_check_24);
|
this.binding.acceptCall.setImageResource(R.drawable.ic_baseline_check_24);
|
||||||
this.binding.acceptCall.setVisibility(View.VISIBLE);
|
this.binding.acceptCall.setVisibility(View.VISIBLE);
|
||||||
} else if (state == RtpEndUserState.DECLINED_OR_BUSY) {
|
} else if (asList(RtpEndUserState.DECLINED_OR_BUSY, RtpEndUserState.CONTACT_OFFLINE)
|
||||||
|
.contains(state)) {
|
||||||
this.binding.rejectCall.setContentDescription(getString(R.string.exit));
|
this.binding.rejectCall.setContentDescription(getString(R.string.exit));
|
||||||
this.binding.rejectCall.setOnClickListener(this::exit);
|
this.binding.rejectCall.setOnClickListener(this::exit);
|
||||||
this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp);
|
this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp);
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
package eu.siacs.conversations.xmpp.jingle;
|
package eu.siacs.conversations.xmpp.jingle;
|
||||||
|
|
||||||
public enum RtpEndUserState {
|
public enum RtpEndUserState {
|
||||||
INCOMING_CALL, //received a 'propose' message
|
INCOMING_CALL, // received a 'propose' message
|
||||||
CONNECTING, //session-initiate or session-accepted but no webrtc peer connection yet
|
CONNECTING, // session-initiate or session-accepted but no webrtc peer connection yet
|
||||||
CONNECTED, //session-accepted and webrtc peer connection is connected
|
CONNECTED, // session-accepted and webrtc peer connection is connected
|
||||||
RECONNECTING, //session-accepted and webrtc peer connection was connected once but is currently disconnected or failed
|
RECONNECTING, // session-accepted and webrtc peer connection was connected once but is currently
|
||||||
INCOMING_CONTENT_ADD, //session-accepted with a pending, incoming content-add
|
// disconnected or failed
|
||||||
FINDING_DEVICE, //'propose' has been sent out; no 184 ack yet
|
INCOMING_CONTENT_ADD, // session-accepted with a pending, incoming content-add
|
||||||
RINGING, //'propose' has been sent out and it has been 184 acked
|
FINDING_DEVICE, // 'propose' has been sent out; no 184 ack yet
|
||||||
ACCEPTING_CALL, //'proceed' message has been sent; but no session-initiate has been received
|
RINGING, // 'propose' has been sent out and it has been 184 acked
|
||||||
ENDING_CALL, //libwebrt says 'closed' but session-terminate has not gone through
|
ACCEPTING_CALL, // 'proceed' message has been sent; but no session-initiate has been received
|
||||||
ENDED, //close UI
|
ENDING_CALL, // libwebrt says 'closed' but session-terminate has not gone through
|
||||||
DECLINED_OR_BUSY, //other party declined; no retry button
|
ENDED, // close UI
|
||||||
CONNECTIVITY_ERROR, //network error; retry button
|
DECLINED_OR_BUSY, // other party declined; no retry button
|
||||||
CONNECTIVITY_LOST_ERROR, //network error but for call duration > 0
|
CONTACT_OFFLINE, // when `JINGLE_MESSAGE_INIT_STRICT_OFFLINE_CHECK` is true this shows up when
|
||||||
RETRACTED, //user pressed home or power button during 'ringing' - shows retry button
|
// the contact is offline, generally similar to BUSY
|
||||||
APPLICATION_ERROR, //something rather bad happened; libwebrtc failed or we got in IQ-error
|
CONNECTIVITY_ERROR, // network error; retry button
|
||||||
SECURITY_ERROR //problem with DTLS (missing) or verification
|
CONNECTIVITY_LOST_ERROR, // network error but for call duration > 0
|
||||||
|
RETRACTED, // user pressed home or power button during 'ringing' - shows retry button
|
||||||
|
APPLICATION_ERROR, // something rather bad happened; libwebrtc failed or we got in IQ-error
|
||||||
|
SECURITY_ERROR // problem with DTLS (missing) or verification
|
||||||
}
|
}
|
||||||
|
|
|
@ -929,6 +929,7 @@
|
||||||
<string name="rtp_state_finding_device">Discovering devices</string>
|
<string name="rtp_state_finding_device">Discovering devices</string>
|
||||||
<string name="rtp_state_ringing">Ringing</string>
|
<string name="rtp_state_ringing">Ringing</string>
|
||||||
<string name="rtp_state_declined_or_busy">Busy</string>
|
<string name="rtp_state_declined_or_busy">Busy</string>
|
||||||
|
<string name="rtp_state_contact_offline">Contact is not available</string>
|
||||||
<string name="rtp_state_connectivity_error">Could not connect call</string>
|
<string name="rtp_state_connectivity_error">Could not connect call</string>
|
||||||
<string name="rtp_state_connectivity_lost_error">Connection lost</string>
|
<string name="rtp_state_connectivity_lost_error">Connection lost</string>
|
||||||
<string name="rtp_state_retracted">Retracted call</string>
|
<string name="rtp_state_retracted">Retracted call</string>
|
||||||
|
|
Loading…
Reference in a new issue