mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Use strongly-typed ACIs and PNIs everywhere.
This commit is contained in:
@@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder
|
||||
import org.webrtc.PeerConnection;
|
||||
import org.webrtc.VideoTrack;
|
||||
import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -91,7 +92,7 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
|
||||
seen.add(Recipient.self());
|
||||
|
||||
for (GroupCall.RemoteDeviceState device : remoteDeviceStates) {
|
||||
Recipient recipient = Recipient.externalPush(ServiceId.from(device.getUserId()));
|
||||
Recipient recipient = Recipient.externalPush(ACI.from(device.getUserId()));
|
||||
CallParticipantId callParticipantId = new CallParticipantId(device.getDemuxId(), recipient.getId());
|
||||
CallParticipant callParticipant = participants.get(callParticipantId);
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package org.thoughtcrime.securesms.service.webrtc
|
||||
import org.signal.ringrtc.CallManager
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import java.util.UUID
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI
|
||||
|
||||
data class GroupCallRingCheckInfo(
|
||||
val recipientId: RecipientId,
|
||||
val groupId: GroupId.V2,
|
||||
val ringId: Long,
|
||||
val ringerUuid: UUID,
|
||||
val ringerAci: ACI,
|
||||
val ringUpdate: CallManager.RingUpdate
|
||||
)
|
||||
|
||||
@@ -158,8 +158,8 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId, remoteUserRangTheCall, true);
|
||||
|
||||
List<UUID> members = new ArrayList<>(peekInfo.getJoinedMembers());
|
||||
if (!members.contains(SignalStore.account().requireAci().uuid())) {
|
||||
members.add(SignalStore.account().requireAci().uuid());
|
||||
if (!members.contains(SignalStore.account().requireAci().getRawUuid())) {
|
||||
members.add(SignalStore.account().requireAci().getRawUuid());
|
||||
}
|
||||
webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, WebRtcUtil.isCallFull(peekInfo));
|
||||
|
||||
@@ -184,7 +184,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
String eraId = WebRtcUtil.getGroupCallEraId(groupCall);
|
||||
webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId, false, false);
|
||||
|
||||
List<UUID> members = Stream.of(currentState.getCallInfoState().getRemoteCallParticipants()).map(p -> p.getRecipient().requireServiceId().uuid()).toList();
|
||||
List<UUID> members = Stream.of(currentState.getCallInfoState().getRemoteCallParticipants()).map(p -> p.getRecipient().requireServiceId().getRawUuid()).toList();
|
||||
webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, false);
|
||||
|
||||
currentState = currentState.builder()
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder;
|
||||
import org.thoughtcrime.securesms.util.NetworkUtil;
|
||||
import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
import java.util.List;
|
||||
@@ -120,7 +121,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
|
||||
}
|
||||
|
||||
List<Recipient> callParticipants = Stream.of(peekInfo.getJoinedMembers())
|
||||
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid)))
|
||||
.map(uuid -> Recipient.externalPush(ACI.from(uuid)))
|
||||
.toList();
|
||||
|
||||
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder()
|
||||
|
||||
@@ -17,8 +17,7 @@ import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
|
||||
/**
|
||||
* Action handler for when the system is at rest. Mainly responsible
|
||||
@@ -97,7 +96,7 @@ public class IdleActionProcessor extends WebRtcActionProcessor {
|
||||
@NonNull RemotePeer remotePeerGroup,
|
||||
@NonNull GroupId.V2 groupId,
|
||||
long ringId,
|
||||
@NonNull UUID sender,
|
||||
@NonNull ACI sender,
|
||||
@NonNull CallManager.RingUpdate ringUpdate)
|
||||
{
|
||||
Log.i(TAG, "handleGroupCallRingUpdate(): recipient: " + remotePeerGroup.getId() + " ring: " + ringId + " update: " + ringUpdate);
|
||||
@@ -154,11 +153,11 @@ public class IdleActionProcessor extends WebRtcActionProcessor {
|
||||
|
||||
if (peekInfo.getDeviceCount() == 0) {
|
||||
Log.i(TAG, "No one in the group call, mark as expired and do not ring");
|
||||
SignalDatabase.calls().insertOrUpdateGroupCallFromRingState(info.getRingId(), info.getRecipientId(), info.getRingerUuid(), System.currentTimeMillis(), CallManager.RingUpdate.EXPIRED_REQUEST);
|
||||
SignalDatabase.calls().insertOrUpdateGroupCallFromRingState(info.getRingId(), info.getRecipientId(), info.getRingerAci(), System.currentTimeMillis(), CallManager.RingUpdate.EXPIRED_REQUEST);
|
||||
return currentState;
|
||||
} else if (peekInfo.getJoinedMembers().contains(Recipient.self().requireServiceId().uuid())) {
|
||||
} else if (peekInfo.getJoinedMembers().contains(Recipient.self().requireServiceId().getRawUuid())) {
|
||||
Log.i(TAG, "We are already in the call, mark accepted on another device and do not ring");
|
||||
SignalDatabase.calls().insertOrUpdateGroupCallFromRingState(info.getRingId(), info.getRecipientId(), info.getRingerUuid(), System.currentTimeMillis(), CallManager.RingUpdate.ACCEPTED_ON_ANOTHER_DEVICE);
|
||||
SignalDatabase.calls().insertOrUpdateGroupCallFromRingState(info.getRingId(), info.getRecipientId(), info.getRingerAci(), System.currentTimeMillis(), CallManager.RingUpdate.ACCEPTED_ON_ANOTHER_DEVICE);
|
||||
return currentState;
|
||||
}
|
||||
|
||||
@@ -166,6 +165,6 @@ public class IdleActionProcessor extends WebRtcActionProcessor {
|
||||
.actionProcessor(new IncomingGroupCallActionProcessor(webRtcInteractor))
|
||||
.build();
|
||||
|
||||
return currentState.getActionProcessor().handleGroupCallRingUpdate(currentState, new RemotePeer(info.getRecipientId()), info.getGroupId(), info.getRingId(), info.getRingerUuid(), info.getRingUpdate());
|
||||
return currentState.getActionProcessor().handleGroupCallRingUpdate(currentState, new RemotePeer(info.getRecipientId()), info.getGroupId(), info.getRingId(), info.getRingerAci(), info.getRingUpdate());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.util.NetworkUtil;
|
||||
import org.thoughtcrime.securesms.webrtc.locks.LockManager;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -49,7 +50,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
||||
@NonNull RemotePeer remotePeerGroup,
|
||||
@NonNull GroupId.V2 groupId,
|
||||
long ringId,
|
||||
@NonNull UUID sender,
|
||||
@NonNull ACI sender,
|
||||
@NonNull CallManager.RingUpdate ringUpdate)
|
||||
{
|
||||
Log.i(TAG, "handleGroupCallRingUpdate(): recipient: " + remotePeerGroup.getId() + " ring: " + Long.toHexString(ringId) + " update: " + ringUpdate);
|
||||
@@ -108,7 +109,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
||||
|
||||
Log.i(TAG, "Requesting new ring: " + Long.toHexString(ringId));
|
||||
|
||||
Recipient ringerRecipient = Recipient.externalPush(ServiceId.from(sender));
|
||||
Recipient ringerRecipient = Recipient.externalPush(sender);
|
||||
SignalDatabase.calls().insertOrUpdateGroupCallFromRingState(
|
||||
ringId,
|
||||
remotePeerGroup.getId(),
|
||||
|
||||
@@ -80,7 +80,7 @@ import org.whispersystems.signalservice.api.messages.calls.OpaqueMessage;
|
||||
import org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage;
|
||||
import org.whispersystems.signalservice.api.messages.calls.TurnServerInfo;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.SyncMessage;
|
||||
|
||||
@@ -191,7 +191,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
serviceExecutor.execute(() -> {
|
||||
if (needsToSetSelfUuid) {
|
||||
try {
|
||||
callManager.setSelfUuid(SignalStore.account().requireAci().uuid());
|
||||
callManager.setSelfUuid(SignalStore.account().requireAci().getRawUuid());
|
||||
needsToSetSelfUuid = false;
|
||||
} catch (CallException e) {
|
||||
Log.w(TAG, "Unable to set self UUID on CallManager", e);
|
||||
@@ -724,14 +724,14 @@ private void processStateless(@NonNull Function1<WebRtcEphemeralState, WebRtcEph
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendCallMessage(@NonNull UUID uuid, @NonNull byte[] bytes, @NonNull CallManager.CallMessageUrgency urgency) {
|
||||
public void onSendCallMessage(@NonNull UUID aciUuid, @NonNull byte[] bytes, @NonNull CallManager.CallMessageUrgency urgency) {
|
||||
Log.i(TAG, "onSendCallMessage():");
|
||||
|
||||
OpaqueMessage opaqueMessage = new OpaqueMessage(bytes, getUrgencyFromCallUrgency(urgency));
|
||||
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOpaque(opaqueMessage, true, null);
|
||||
|
||||
networkExecutor.execute(() -> {
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(ServiceId.from(uuid)));
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(ACI.from(aciUuid)));
|
||||
if (recipient.isBlocked()) {
|
||||
return;
|
||||
}
|
||||
@@ -826,16 +826,17 @@ private void processStateless(@NonNull Function1<WebRtcEphemeralState, WebRtcEph
|
||||
@Override
|
||||
public void onGroupCallRingUpdate(@NonNull byte[] groupIdBytes, long ringId, @NonNull UUID sender, @NonNull CallManager.RingUpdate ringUpdate) {
|
||||
try {
|
||||
ACI senderAci = ACI.from(sender);
|
||||
GroupId.V2 groupId = GroupId.v2(new GroupIdentifier(groupIdBytes));
|
||||
GroupRecord group = SignalDatabase.groups().getGroup(groupId).orElse(null);
|
||||
Recipient senderRecipient = Recipient.externalPush(ServiceId.from(sender));
|
||||
Recipient senderRecipient = Recipient.externalPush(senderAci);
|
||||
|
||||
if (group != null &&
|
||||
group.isActive() &&
|
||||
!Recipient.resolved(group.getRecipientId()).isBlocked() &&
|
||||
(!group.isAnnouncementGroup() || group.isAdmin(senderRecipient)))
|
||||
{
|
||||
process((s, p) -> p.handleGroupCallRingUpdate(s, new RemotePeer(group.getRecipientId()), groupId, ringId, sender, ringUpdate));
|
||||
process((s, p) -> p.handleGroupCallRingUpdate(s, new RemotePeer(group.getRecipientId()), groupId, ringId, senderAci, ringUpdate));
|
||||
} else {
|
||||
Log.w(TAG, "Unable to ring unknown/inactive/blocked group.");
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.whispersystems.signalservice.api.messages.calls.HangupMessage;
|
||||
import org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage;
|
||||
import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
|
||||
import org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -789,7 +790,7 @@ public abstract class WebRtcActionProcessor {
|
||||
@NonNull RemotePeer remotePeerGroup,
|
||||
@NonNull GroupId.V2 groupId,
|
||||
long ringId,
|
||||
@NonNull UUID sender,
|
||||
@NonNull ACI sender,
|
||||
@NonNull RingUpdate ringUpdate)
|
||||
{
|
||||
Log.i(tag, "handleGroupCallRingUpdate(): recipient: " + remotePeerGroup.getId() + " ring: " + ringId + " update: " + ringUpdate);
|
||||
|
||||
@@ -45,7 +45,7 @@ class SignalCallLinkManager(
|
||||
linkRootKey: ByteArray,
|
||||
roomId: ByteArray
|
||||
): CreateCallLinkCredentialPresentation {
|
||||
val userUuid = Recipient.self().requireServiceId().uuid()
|
||||
val userUuid = Recipient.self().requireAci().rawUuid
|
||||
val requestContext = CreateCallLinkCredentialRequestContext.forRoom(roomId)
|
||||
val request = requestContext.request
|
||||
|
||||
|
||||
Reference in New Issue
Block a user