create rtp end user state for connection lost. fixes #3769

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java           | 11 
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java |  4 
src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java     |  1 
src/main/res/values/strings.xml                                           |  1 
4 files changed, 14 insertions(+), 3 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java 🔗

@@ -78,6 +78,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
             RtpEndUserState.APPLICATION_ERROR,
             RtpEndUserState.DECLINED_OR_BUSY,
             RtpEndUserState.CONNECTIVITY_ERROR,
+            RtpEndUserState.CONNECTIVITY_LOST_ERROR,
             RtpEndUserState.RETRACTED
     );
     private static final String PROXIMITY_WAKE_LOCK_TAG = "conversations:in-rtp-session";
@@ -533,6 +534,9 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
             case CONNECTIVITY_ERROR:
                 setTitle(R.string.rtp_state_connectivity_error);
                 break;
+            case CONNECTIVITY_LOST_ERROR:
+                setTitle(R.string.rtp_state_connectivity_lost_error);
+                break;
             case RETRACTED:
                 setTitle(R.string.rtp_state_retracted);
                 break;
@@ -598,7 +602,12 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
             this.binding.acceptCall.setOnClickListener(this::recordVoiceMail);
             this.binding.acceptCall.setImageResource(R.drawable.ic_voicemail_white_24dp);
             this.binding.acceptCall.setVisibility(View.VISIBLE);
-        } else if (asList(RtpEndUserState.CONNECTIVITY_ERROR, RtpEndUserState.APPLICATION_ERROR, RtpEndUserState.RETRACTED).contains(state)) {
+        } else if (asList(
+                RtpEndUserState.CONNECTIVITY_ERROR,
+                RtpEndUserState.CONNECTIVITY_LOST_ERROR,
+                RtpEndUserState.APPLICATION_ERROR,
+                RtpEndUserState.RETRACTED
+        ).contains(state)) {
             this.binding.rejectCall.setOnClickListener(this::exit);
             this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp);
             this.binding.rejectCall.setVisibility(View.VISIBLE);

src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java 🔗

@@ -814,7 +814,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
                 } else if (state == PeerConnection.PeerConnectionState.CLOSED) {
                     return RtpEndUserState.ENDING_CALL;
                 } else {
-                    return RtpEndUserState.CONNECTIVITY_ERROR;
+                    return rtpConnectionStarted == 0 ? RtpEndUserState.CONNECTIVITY_ERROR : RtpEndUserState.CONNECTIVITY_LOST_ERROR;
                 }
             case REJECTED:
             case TERMINATED_DECLINED_OR_BUSY:
@@ -831,7 +831,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
             case RETRACTED_RACED:
                 return RtpEndUserState.RETRACTED;
             case TERMINATED_CONNECTIVITY_ERROR:
-                return RtpEndUserState.CONNECTIVITY_ERROR;
+                return rtpConnectionStarted == 0 ? RtpEndUserState.CONNECTIVITY_ERROR : RtpEndUserState.CONNECTIVITY_LOST_ERROR;
             case TERMINATED_APPLICATION_FAILURE:
                 return RtpEndUserState.APPLICATION_ERROR;
         }

src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java 🔗

@@ -11,6 +11,7 @@ public enum RtpEndUserState {
     ENDED, //close UI
     DECLINED_OR_BUSY, //other party declined; no retry button
     CONNECTIVITY_ERROR, //network error; retry button
+    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
 }

src/main/res/values/strings.xml 🔗

@@ -903,6 +903,7 @@
     <string name="rtp_state_ringing">Ringing</string>
     <string name="rtp_state_declined_or_busy">Busy</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_retracted">Retracted call</string>
     <string name="rtp_state_application_failure">App failure</string>
     <string name="hang_up">Hang up</string>