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() {
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);

View file

@ -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);
}
}
}

View file

@ -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
}

View file

@ -904,6 +904,7 @@
<string name="rtp_state_ringing">Ringing</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_retracted">Retracted call</string>
<string name="rtp_state_application_failure">Application failure</string>
<string name="hang_up">Hang up</string>
<string name="ongoing_call">Ongoing call</string>