retract call when pressing home or power button during ringing

This commit is contained in:
Daniel Gultsch 2020-04-21 22:46:46 +02:00
parent e5282b846f
commit e0cb127005
4 changed files with 18 additions and 6 deletions

View File

@ -95,16 +95,21 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
private void endCall() { private void endCall() {
if (this.rtpConnectionReference == null) { if (this.rtpConnectionReference == null) {
final Intent intent = getIntent(); retractSessionProposal();
final Account account = extractAccount(intent);
final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH));
xmppConnectionService.getJingleConnectionManager().retractSessionProposal(account, with.asBareJid());
finish(); finish();
} else { } else {
requireRtpConnection().endCall(); 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) { private void rejectCall(View view) {
requireRtpConnection().rejectCall(); requireRtpConnection().rejectCall();
finish(); finish();
@ -290,6 +295,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
final JingleRtpConnection jingleRtpConnection = weakReference == null ? null : weakReference.get(); final JingleRtpConnection jingleRtpConnection = weakReference == null ? null : weakReference.get();
if (jingleRtpConnection != null) { if (jingleRtpConnection != null) {
releaseVideoTracks(jingleRtpConnection); releaseVideoTracks(jingleRtpConnection);
} else if (!isChangingConfigurations()) {
retractSessionProposal();
} }
releaseProximityWakeLock(); releaseProximityWakeLock();
super.onStop(); super.onStop();
@ -420,6 +427,9 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
case CONNECTIVITY_ERROR: case CONNECTIVITY_ERROR:
setTitle(R.string.rtp_state_connectivity_error); setTitle(R.string.rtp_state_connectivity_error);
break; break;
case RETRACTED:
setTitle(R.string.rtp_state_retracted);
break;
case APPLICATION_ERROR: case APPLICATION_ERROR:
setTitle(R.string.rtp_state_application_failure); setTitle(R.string.rtp_state_application_failure);
break; 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.setImageResource(R.drawable.ic_clear_white_48dp);
this.binding.endCall.setVisibility(View.VISIBLE); this.binding.endCall.setVisibility(View.VISIBLE);
this.binding.acceptCall.setVisibility(View.INVISIBLE); 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.setOnClickListener(this::exit);
this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp); this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp);
this.binding.rejectCall.setVisibility(View.VISIBLE); this.binding.rejectCall.setVisibility(View.VISIBLE);

View File

@ -402,11 +402,11 @@ public class JingleConnectionManager extends AbstractConnectionManager {
} }
} }
if (matchingProposal != null) { if (matchingProposal != null) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retracting rtp session proposal with " + with);
this.rtpSessionProposals.remove(matchingProposal); this.rtpSessionProposals.remove(matchingProposal);
final MessagePacket messagePacket = mXmppConnectionService.getMessageGenerator().sessionRetract(matchingProposal); final MessagePacket messagePacket = mXmppConnectionService.getMessageGenerator().sessionRetract(matchingProposal);
writeLogMissedOutgoing(account, matchingProposal.with, matchingProposal.sessionId, null, System.currentTimeMillis()); writeLogMissedOutgoing(account, matchingProposal.with, matchingProposal.sessionId, null, System.currentTimeMillis());
mXmppConnectionService.sendMessagePacket(account, messagePacket); mXmppConnectionService.sendMessagePacket(account, messagePacket);
} }
} }
} }

View File

@ -11,5 +11,6 @@ public enum RtpEndUserState {
ENDED, //close UI ENDED, //close UI
DECLINED_OR_BUSY, //other party declined; no retry button DECLINED_OR_BUSY, //other party declined; no retry button
CONNECTIVITY_ERROR, //network error; 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 APPLICATION_ERROR //something rather bad happened; libwebrtc failed or we got in IQ-error
} }

View File

@ -904,6 +904,7 @@
<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_connectivity_error">Unable to connect call</string> <string name="rtp_state_connectivity_error">Unable to connect call</string>
<string name="rtp_state_retracted">Retracted call</string>
<string name="rtp_state_application_failure">Application failure</string> <string name="rtp_state_application_failure">Application failure</string>
<string name="hang_up">Hang up</string> <string name="hang_up">Hang up</string>
<string name="ongoing_call">Ongoing call</string> <string name="ongoing_call">Ongoing call</string>