From e0cb127005fac54904350f2359b573fc80a85f11 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 21 Apr 2020 22:46:46 +0200 Subject: [PATCH] retract call when pressing home or power button during ringing --- .../conversations/ui/RtpSessionActivity.java | 20 ++++++++++++++----- .../xmpp/jingle/JingleConnectionManager.java | 2 +- .../xmpp/jingle/RtpEndUserState.java | 1 + src/main/res/values/strings.xml | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index f85ad3f4e4768c987c394863ab73806eb93b3cc9..0b671453a041285b69d568cd6a9c517d82634ae8 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -95,16 +95,21 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe private void endCall() { if (this.rtpConnectionReference == null) { - final Intent intent = getIntent(); - final Account account = extractAccount(intent); - final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); - xmppConnectionService.getJingleConnectionManager().retractSessionProposal(account, with.asBareJid()); + retractSessionProposal(); finish(); } else { requireRtpConnection().endCall(); } } + private void retractSessionProposal() { + final Intent intent = getIntent(); + final Account account = extractAccount(intent); + final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); + resetIntent(account, with, RtpEndUserState.RETRACTED, actionToMedia(intent.getAction())); + xmppConnectionService.getJingleConnectionManager().retractSessionProposal(account, with.asBareJid()); + } + private void rejectCall(View view) { requireRtpConnection().rejectCall(); finish(); @@ -290,6 +295,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe final JingleRtpConnection jingleRtpConnection = weakReference == null ? null : weakReference.get(); if (jingleRtpConnection != null) { releaseVideoTracks(jingleRtpConnection); + } else if (!isChangingConfigurations()) { + retractSessionProposal(); } releaseProximityWakeLock(); super.onStop(); @@ -420,6 +427,9 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe case CONNECTIVITY_ERROR: setTitle(R.string.rtp_state_connectivity_error); break; + case RETRACTED: + setTitle(R.string.rtp_state_retracted); + break; case APPLICATION_ERROR: setTitle(R.string.rtp_state_application_failure); break; @@ -468,7 +478,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe this.binding.endCall.setImageResource(R.drawable.ic_clear_white_48dp); this.binding.endCall.setVisibility(View.VISIBLE); this.binding.acceptCall.setVisibility(View.INVISIBLE); - } else if (state == RtpEndUserState.CONNECTIVITY_ERROR || state == RtpEndUserState.APPLICATION_ERROR) { + } else if (asList(RtpEndUserState.CONNECTIVITY_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); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index b2564785474a833fff2789f72c804853c3c4fbd4..07d6a25cb81c613bb6267e48964c400a2ecd6ff2 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -402,11 +402,11 @@ public class JingleConnectionManager extends AbstractConnectionManager { } } if (matchingProposal != null) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retracting rtp session proposal with " + with); this.rtpSessionProposals.remove(matchingProposal); final MessagePacket messagePacket = mXmppConnectionService.getMessageGenerator().sessionRetract(matchingProposal); writeLogMissedOutgoing(account, matchingProposal.with, matchingProposal.sessionId, null, System.currentTimeMillis()); mXmppConnectionService.sendMessagePacket(account, messagePacket); - } } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java index 4baa0019d397172abd3a38a137536fb438b9f3b9..398777cfec9c1b69c56e1bc370f6b0b22831fd9b 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java @@ -11,5 +11,6 @@ public enum RtpEndUserState { ENDED, //close UI DECLINED_OR_BUSY, //other party declined; no retry button CONNECTIVITY_ERROR, //network error; retry button + 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 } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 32ade63875e49ceb4e0e61f1f787ce8575c44936..48ca72cea25773eb2ef471f9cfeb718ac4cc4eb2 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -904,6 +904,7 @@ Ringing Busy Unable to connect call + Retracted call Application failure Hang up Ongoing call