Add group call NOT_ACCEPTED sync handling.

This commit is contained in:
Cody Henthorne
2023-11-20 10:03:37 -05:00
parent 428f963243
commit 6d3924ba43
8 changed files with 137 additions and 19 deletions

View File

@@ -155,7 +155,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
boolean remoteUserRangTheCall = currentState.getCallSetupState(RemotePeer.GROUP_CALL_ID).getRingerRecipient() != Recipient.self();
String eraId = WebRtcUtil.getGroupCallEraId(groupCall);
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId, remoteUserRangTheCall, true);
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId, null, remoteUserRangTheCall, true);
List<UUID> members = new ArrayList<>(peekInfo.getJoinedMembers());
if (!members.contains(SignalStore.account().requireAci().getRawUuid())) {
@@ -182,7 +182,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
}
String eraId = WebRtcUtil.getGroupCallEraId(groupCall);
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId, false, false);
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId, null, false, false);
List<UUID> members = Stream.of(currentState.getCallInfoState().getRemoteCallParticipants()).map(p -> p.getRecipient().requireServiceId().getRawUuid()).toList();
webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, false);

View File

@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
import org.signal.core.util.logging.Log;
import org.signal.ringrtc.CallException;
import org.signal.ringrtc.CallId;
import org.signal.ringrtc.CallManager;
import org.signal.ringrtc.GroupCall;
import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink;
@@ -233,6 +234,8 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
@Override
protected @NonNull WebRtcServiceState handleDenyCall(@NonNull WebRtcServiceState currentState) {
Log.i(TAG, "handleDenyCall():");
Recipient recipient = currentState.getCallInfoState().getCallRecipient();
Optional<GroupId> groupId = recipient.getGroupId();
long ringId = currentState.getCallSetupState(RemotePeer.GROUP_CALL_ID).getRingId();
@@ -252,6 +255,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
Log.w(TAG, "Error while trying to cancel ring " + ringId, e);
}
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), null, new CallId(ringId), true, false);
webRtcInteractor.updatePhoneState(LockManager.PhoneState.PROCESSING);
webRtcInteractor.stopAudio(false);
webRtcInteractor.updatePhoneState(LockManager.PhoneState.IDLE);

View File

@@ -1009,7 +1009,9 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
});
}
public void sendGroupCallUpdateMessage(@NonNull Recipient recipient, @Nullable String groupCallEraId, boolean isIncoming, boolean isJoinEvent) {
public void sendGroupCallUpdateMessage(@NonNull Recipient recipient, @Nullable String groupCallEraId, final @Nullable CallId callId, boolean isIncoming, boolean isJoinEvent) {
Log.i(TAG, "sendGroupCallUpdateMessage id: " + recipient.getId() + " era: " + groupCallEraId + " isIncoming: " + isIncoming + " isJoinEvent: " + isJoinEvent);
if (recipient.isCallLink()) {
Log.i(TAG, "sendGroupCallUpdateMessage -- ignoring for call link");
return;
@@ -1018,15 +1020,28 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
SignalExecutors.BOUNDED.execute(() -> {
GroupCallUpdateSendJob updateSendJob = GroupCallUpdateSendJob.create(recipient.getId(), groupCallEraId);
JobManager.Chain chain = ApplicationDependencies.getJobManager().startChain(updateSendJob);
CallId callIdLocal = callId;
if (isJoinEvent && groupCallEraId != null) {
chain.then(CallSyncEventJob.createForJoin(
recipient.getId(),
CallId.fromEra(groupCallEraId).longValue(),
isIncoming
));
} else if (isJoinEvent) {
Log.w(TAG, "Can't send join event sync message without an era id.");
if (callIdLocal == null && groupCallEraId != null) {
callIdLocal = CallId.fromEra(groupCallEraId);
}
if (callIdLocal != null) {
if (isJoinEvent) {
chain.then(CallSyncEventJob.createForJoin(
recipient.getId(),
callIdLocal.longValue(),
isIncoming
));
} else if (isIncoming) {
chain.then(CallSyncEventJob.createForNotAccepted(
recipient.getId(),
callIdLocal.longValue(),
isIncoming
));
}
} else {
Log.w(TAG, "Can't send sync message without a call id. isIncoming: " + isIncoming + " isJoinEvent: " + isJoinEvent);
}
chain.enqueue();

View File

@@ -828,7 +828,7 @@ public abstract class WebRtcActionProcessor {
Recipient recipient = currentState.getCallInfoState().getCallRecipient();
if (recipient != null && currentState.getCallInfoState().getGroupCallState().isConnected()) {
webRtcInteractor.sendGroupCallMessage(recipient, WebRtcUtil.getGroupCallEraId(groupCall), false, false);
webRtcInteractor.sendGroupCallMessage(recipient, WebRtcUtil.getGroupCallEraId(groupCall), null, false, false);
}
currentState = currentState.builder()

View File

@@ -5,8 +5,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import org.signal.ringrtc.CallId;
import org.signal.ringrtc.CallManager;
import org.signal.ringrtc.GroupCall;
import org.thoughtcrime.securesms.groups.GroupId;
@@ -85,8 +85,8 @@ public class WebRtcInteractor {
signalCallManager.sendCallMessage(remotePeer, callMessage);
}
void sendGroupCallMessage(@NonNull Recipient recipient, @Nullable String groupCallEraId, boolean isIncoming, boolean isJoinEvent) {
signalCallManager.sendGroupCallUpdateMessage(recipient, groupCallEraId, isIncoming, isJoinEvent);
void sendGroupCallMessage(@NonNull Recipient recipient, @Nullable String groupCallEraId, @Nullable CallId callId, boolean isIncoming, boolean isJoinEvent) {
signalCallManager.sendGroupCallUpdateMessage(recipient, groupCallEraId, callId, isIncoming, isJoinEvent);
}
void updateGroupCallUpdateMessage(@NonNull RecipientId groupId, @Nullable String groupCallEraId, @NonNull Collection<UUID> joinedMembers, boolean isCallFull) {