From 96bf407bf0ff13becd2b245f17e6e6c6f0370922 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 8 Apr 2024 14:12:30 +0200 Subject: [PATCH] fix rare crashes in call integration --- .../eu/siacs/conversations/services/CallIntegration.java | 3 ++- .../services/CallIntegrationConnectionService.java | 6 ++++++ .../conversations/xmpp/jingle/JingleConnectionManager.java | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/CallIntegration.java b/src/main/java/eu/siacs/conversations/services/CallIntegration.java index 93b25e25f..86a824ffb 100644 --- a/src/main/java/eu/siacs/conversations/services/CallIntegration.java +++ b/src/main/java/eu/siacs/conversations/services/CallIntegration.java @@ -297,7 +297,8 @@ public class CallIntegration extends Connection { } private AudioDevice getAudioDeviceFallback() { - return requireAppRtcAudioManager().getSelectedAudioDevice(); + final var audioDevice = requireAppRtcAudioManager().getSelectedAudioDevice(); + return audioDevice == null ? AudioDevice.NONE : audioDevice; } private void setAudioDeviceFallback(final AudioDevice audioDevice) { diff --git a/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java b/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java index ce4d9fb8a..a234fc781 100644 --- a/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/CallIntegrationConnectionService.java @@ -128,6 +128,12 @@ public class CallIntegrationConnectionService extends ConnectionService { final var proposal = service.getJingleConnectionManager() .proposeJingleRtpSession(account, with, media); + if (proposal == null) { + // TODO instead of just null checking try to get the sessionID + return Connection.createFailedConnection( + new DisconnectCause( + DisconnectCause.ERROR, "a call is already in progress")); + } intent.putExtra( RtpSessionActivity.EXTRA_LAST_REPORTED_STATE, RtpEndUserState.FINDING_DEVICE.toString()); 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 ce3628697..b1545a2fc 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -4,6 +4,8 @@ import android.telecom.VideoProfile; import android.util.Base64; import android.util.Log; +import androidx.annotation.Nullable; + import com.google.common.base.Objects; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -727,7 +729,7 @@ public class JingleConnectionManager extends AbstractConnectionManager { return rtpConnection; } - public RtpSessionProposal proposeJingleRtpSession( + public @Nullable RtpSessionProposal proposeJingleRtpSession( final Account account, final Jid with, final Set media) { synchronized (this.rtpSessionProposals) { for (final Map.Entry entry :