Remove legacy call message fields

This commit is contained in:
Jim Gustafson 2024-01-04 16:19:43 -08:00 committed by Alex Hart
parent 5022d81d9a
commit 78b714e019
10 changed files with 40 additions and 108 deletions

View file

@ -40,9 +40,7 @@ object CallMessageProcessor {
callMessage.offer != null -> handleCallOfferMessage(envelope, metadata, callMessage.offer!!, senderRecipient.id, serverDeliveredTimestamp)
callMessage.answer != null -> handleCallAnswerMessage(envelope, metadata, callMessage.answer!!, senderRecipient.id)
callMessage.iceUpdate.isNotEmpty() -> handleCallIceUpdateMessage(envelope, metadata, callMessage.iceUpdate, senderRecipient.id)
callMessage.hangup != null || callMessage.legacyHangup != null -> {
handleCallHangupMessage(envelope, metadata, callMessage.hangup ?: callMessage.legacyHangup, senderRecipient.id)
}
callMessage.hangup != null -> handleCallHangupMessage(envelope, metadata, callMessage.hangup!!, senderRecipient.id)
callMessage.busy != null -> handleCallBusyMessage(envelope, metadata, callMessage.busy!!, senderRecipient.id)
callMessage.opaque != null -> handleCallOpaqueMessage(envelope, metadata, callMessage.opaque!!, senderRecipient.requireAci(), serverDeliveredTimestamp)
}
@ -51,10 +49,10 @@ object CallMessageProcessor {
private fun handleCallOfferMessage(envelope: Envelope, metadata: EnvelopeMetadata, offer: Offer, senderRecipientId: RecipientId, serverDeliveredTimestamp: Long) {
log(envelope.timestamp!!, "handleCallOfferMessage...")
val offerId = if (offer.id != null && offer.type != null && ((offer.opaque != null) xor (offer.sdp != null))) {
val offerId = if (offer.id != null && offer.type != null && offer.opaque != null) {
offer.id!!
} else {
warn(envelope.timestamp!!, "Invalid offer, missing id/type, or invalid combination of opaque/sdp")
warn(envelope.timestamp!!, "Invalid offer, missing id, type, or opaque")
return
}
@ -64,7 +62,7 @@ object CallMessageProcessor {
ApplicationDependencies.getSignalCallManager()
.receivedOffer(
CallMetadata(remotePeer, metadata.sourceDeviceId),
OfferMetadata(offer.opaque?.toByteArray(), offer.sdp, OfferMessage.Type.fromProto(offer.type!!)),
OfferMetadata(offer.opaque?.toByteArray(), OfferMessage.Type.fromProto(offer.type!!)),
ReceivedOfferMetadata(
remoteIdentityKey,
envelope.serverTimestamp!!,
@ -81,10 +79,10 @@ object CallMessageProcessor {
) {
log(envelope.timestamp!!, "handleCallAnswerMessage...")
val answerId = if (answer.id != null && ((answer.opaque != null) xor (answer.sdp != null))) {
val answerId = if (answer.id != null && answer.opaque != null) {
answer.id!!
} else {
warn(envelope.timestamp!!, "Invalid answer, missing id")
warn(envelope.timestamp!!, "Invalid answer, missing id or opaque")
return
}
@ -94,7 +92,7 @@ object CallMessageProcessor {
ApplicationDependencies.getSignalCallManager()
.receivedAnswer(
CallMetadata(remotePeer, metadata.sourceDeviceId),
AnswerMetadata(answer.opaque?.toByteArray(), answer.sdp),
AnswerMetadata(answer.opaque?.toByteArray()),
ReceivedAnswerMetadata(remoteIdentityKey)
)
}

View file

@ -678,7 +678,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
OfferMessage.Type offerType = WebRtcUtil.getOfferTypeFromCallMediaType(callMediaType);
WebRtcData.CallMetadata callMetadata = new WebRtcData.CallMetadata(remotePeer, remoteDevice);
WebRtcData.OfferMetadata offerMetadata = new WebRtcData.OfferMetadata(opaque, null, offerType);
WebRtcData.OfferMetadata offerMetadata = new WebRtcData.OfferMetadata(opaque, offerType);
process((s, p) -> p.handleSendOffer(s, callMetadata, offerMetadata, broadcast));
}
@ -699,7 +699,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
Log.i(TAG, "onSendAnswer: id: " + remotePeer.getCallId().format(remoteDevice));
WebRtcData.CallMetadata callMetadata = new WebRtcData.CallMetadata(remotePeer, remoteDevice);
WebRtcData.AnswerMetadata answerMetadata = new WebRtcData.AnswerMetadata(opaque, null);
WebRtcData.AnswerMetadata answerMetadata = new WebRtcData.AnswerMetadata(opaque);
process((s, p) -> p.handleSendAnswer(s, callMetadata, answerMetadata, broadcast));
}
@ -760,7 +760,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
Log.i(TAG, "onSendCallMessage():");
OpaqueMessage opaqueMessage = new OpaqueMessage(bytes, getUrgencyFromCallUrgency(urgency));
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOpaque(opaqueMessage, true, null);
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOpaque(opaqueMessage, null);
networkExecutor.execute(() -> {
Recipient recipient = Recipient.resolved(RecipientId.from(ACI.from(aciUuid)));
@ -797,7 +797,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
.collect(Collectors.toList())));
OpaqueMessage opaqueMessage = new OpaqueMessage(message, getUrgencyFromCallUrgency(urgency));
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOutgoingGroupOpaque(groupId.getDecodedId(), System.currentTimeMillis(), opaqueMessage, true, null);
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOutgoingGroupOpaque(groupId.getDecodedId(), System.currentTimeMillis(), opaqueMessage, null);
RecipientAccessList accessList = new RecipientAccessList(recipients);
List<SendMessageResult> results = GroupSendUtil.sendCallMessage(context,

View file

@ -132,9 +132,9 @@ public abstract class WebRtcActionProcessor {
protected final @NonNull WebRtcServiceState handleSendOffer(@NonNull WebRtcServiceState currentState, @NonNull CallMetadata callMetadata, @NonNull OfferMetadata offerMetadata, boolean broadcast) {
Log.i(tag, "handleSendOffer(): id: " + callMetadata.getCallId().format(callMetadata.getRemoteDevice()));
OfferMessage offerMessage = new OfferMessage(callMetadata.getCallId().longValue(), offerMetadata.getSdp(), offerMetadata.getOfferType(), offerMetadata.getOpaque());
OfferMessage offerMessage = new OfferMessage(callMetadata.getCallId().longValue(), offerMetadata.getOfferType(), offerMetadata.getOpaque());
Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOffer(offerMessage, true, destinationDeviceId);
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOffer(offerMessage, destinationDeviceId);
Recipient callRecipient = currentState.getCallInfoState().getCallRecipient();
RecipientUtil.shareProfileIfFirstSecureMessage(callRecipient);
@ -320,9 +320,9 @@ public abstract class WebRtcActionProcessor {
{
Log.i(tag, "handleSendAnswer(): id: " + callMetadata.getCallId().format(callMetadata.getRemoteDevice()));
AnswerMessage answerMessage = new AnswerMessage(callMetadata.getCallId().longValue(), answerMetadata.getSdp(), answerMetadata.getOpaque());
AnswerMessage answerMessage = new AnswerMessage(callMetadata.getCallId().longValue(), answerMetadata.getOpaque());
Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forAnswer(answerMessage, true, destinationDeviceId);
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forAnswer(answerMessage, destinationDeviceId);
webRtcInteractor.sendCallMessage(callMetadata.getRemotePeer(), callMessage);
@ -348,7 +348,7 @@ public abstract class WebRtcActionProcessor {
BusyMessage busyMessage = new BusyMessage(callMetadata.getCallId().longValue());
Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forBusy(busyMessage, true, destinationDeviceId);
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forBusy(busyMessage, destinationDeviceId);
webRtcInteractor.sendCallMessage(callMetadata.getRemotePeer(), callMessage);
@ -411,7 +411,7 @@ public abstract class WebRtcActionProcessor {
HangupMessage hangupMessage = new HangupMessage(callMetadata.getCallId().longValue(), hangupMetadata.getType(), hangupMetadata.getDeviceId());
Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forHangup(hangupMessage, true, destinationDeviceId);
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forHangup(hangupMessage, destinationDeviceId);
webRtcInteractor.sendCallMessage(callMetadata.getRemotePeer(), callMessage);
@ -494,11 +494,11 @@ public abstract class WebRtcActionProcessor {
Log.i(tag, "handleSendIceCandidates(): id: " + callMetadata.getCallId().format(callMetadata.getRemoteDevice()));
List<IceUpdateMessage> iceUpdateMessages = Stream.of(iceCandidates)
.map(c -> new IceUpdateMessage(callMetadata.getCallId().longValue(), c, null))
.map(c -> new IceUpdateMessage(callMetadata.getCallId().longValue(), c))
.toList();
Integer destinationDeviceId = broadcast ? null : callMetadata.getRemoteDevice();
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forIceUpdates(iceUpdateMessages, true, destinationDeviceId);
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forIceUpdates(iceUpdateMessages, destinationDeviceId);
webRtcInteractor.sendCallMessage(callMetadata.getRemotePeer(), callMessage);

View file

@ -46,12 +46,10 @@ public class WebRtcData {
*/
public static class OfferMetadata {
private final @Nullable byte[] opaque;
private final @Nullable String sdp;
private final @NonNull OfferMessage.Type offerType;
public OfferMetadata(@Nullable byte[] opaque, @Nullable String sdp, @NonNull OfferMessage.Type offerType) {
public OfferMetadata(@Nullable byte[] opaque, @NonNull OfferMessage.Type offerType) {
this.opaque = opaque;
this.sdp = sdp;
this.offerType = offerType;
}
@ -59,10 +57,6 @@ public class WebRtcData {
return opaque;
}
@Nullable String getSdp() {
return sdp;
}
@NonNull OfferMessage.Type getOfferType() {
return offerType;
}
@ -100,20 +94,14 @@ public class WebRtcData {
*/
public static class AnswerMetadata {
private final @Nullable byte[] opaque;
private final @Nullable String sdp;
public AnswerMetadata(@Nullable byte[] opaque, @Nullable String sdp) {
public AnswerMetadata(@Nullable byte[] opaque) {
this.opaque = opaque;
this.sdp = sdp;
}
@Nullable byte[] getOpaque() {
return opaque;
}
@Nullable String getSdp() {
return sdp;
}
}
/**

View file

@ -1294,10 +1294,6 @@ public class SignalServiceMessageSender {
offerBuilder.opaque(ByteString.of(offer.getOpaque()));
}
if (offer.getSdp() != null) {
offerBuilder.sdp(offer.getSdp());
}
builder.offer(offerBuilder.build());
} else if (callMessage.getAnswerMessage().isPresent()) {
AnswerMessage answer = callMessage.getAnswerMessage().get();
@ -1308,28 +1304,18 @@ public class SignalServiceMessageSender {
answerBuilder.opaque(ByteString.of(answer.getOpaque()));
}
if (answer.getSdp() != null) {
answerBuilder.sdp(answer.getSdp());
}
builder.answer(answerBuilder.build());
} else if (callMessage.getIceUpdateMessages().isPresent()) {
List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get();
List<CallMessage.IceUpdate> iceUpdates = new ArrayList<>(updates.size());
for (IceUpdateMessage update : updates) {
CallMessage.IceUpdate.Builder iceBuilder = new CallMessage.IceUpdate.Builder()
.id(update.getId())
.mid("audio")
.line(0);
.id(update.getId());
if (update.getOpaque() != null) {
iceBuilder.opaque(ByteString.of(update.getOpaque()));
}
if (update.getSdp() != null) {
iceBuilder.sdp(update.getSdp());
}
iceUpdates.add(iceBuilder.build());
}
builder.iceUpdate(iceUpdates);

View file

@ -4,19 +4,13 @@ package org.whispersystems.signalservice.api.messages.calls;
public class AnswerMessage {
private final long id;
private final String sdp;
private final byte[] opaque;
public AnswerMessage(long id, String sdp, byte[] opaque) {
public AnswerMessage(long id, byte[] opaque) {
this.id = id;
this.sdp = sdp;
this.opaque = opaque;
}
public String getSdp() {
return sdp;
}
public long getId() {
return id;
}

View file

@ -5,12 +5,10 @@ public class IceUpdateMessage {
private final long id;
private final byte[] opaque;
private final String sdp;
public IceUpdateMessage(long id, byte[] opaque, String sdp) {
public IceUpdateMessage(long id, byte[] opaque) {
this.id = id;
this.opaque = opaque;
this.sdp = sdp;
}
public long getId() {
@ -20,8 +18,4 @@ public class IceUpdateMessage {
public byte[] getOpaque() {
return opaque;
}
public String getSdp() {
return sdp;
}
}

View file

@ -5,21 +5,15 @@ import org.whispersystems.signalservice.internal.push.CallMessage;
public class OfferMessage {
private final long id;
private final String sdp;
private final Type type;
private final byte[] opaque;
public OfferMessage(long id, String sdp, Type type, byte[] opaque) {
public OfferMessage(long id, Type type, byte[] opaque) {
this.id = id;
this.sdp = sdp;
this.type = type;
this.opaque = opaque;
}
public String getSdp() {
return sdp;
}
public long getId() {
return id;
}

View file

@ -15,7 +15,6 @@ public class SignalServiceCallMessage {
private final Optional<List<IceUpdateMessage>> iceUpdateMessages;
private final Optional<OpaqueMessage> opaqueMessage;
private final Optional<Integer> destinationDeviceId;
private final boolean isMultiRing;
private final Optional<byte[]> groupId;
private final Optional<Long> timestamp;
@ -25,10 +24,9 @@ public class SignalServiceCallMessage {
Optional<HangupMessage> hangupMessage,
Optional<BusyMessage> busyMessage,
Optional<OpaqueMessage> opaqueMessage,
boolean isMultiRing,
Optional<Integer> destinationDeviceId)
{
this(offerMessage, answerMessage, iceUpdateMessages, hangupMessage, busyMessage, opaqueMessage, isMultiRing, destinationDeviceId, Optional.empty(), Optional.empty());
this(offerMessage, answerMessage, iceUpdateMessages, hangupMessage, busyMessage, opaqueMessage, destinationDeviceId, Optional.empty(), Optional.empty());
}
private SignalServiceCallMessage(Optional<OfferMessage> offerMessage,
@ -37,7 +35,6 @@ public class SignalServiceCallMessage {
Optional<HangupMessage> hangupMessage,
Optional<BusyMessage> busyMessage,
Optional<OpaqueMessage> opaqueMessage,
boolean isMultiRing,
Optional<Integer> destinationDeviceId,
Optional<byte[]> groupId,
Optional<Long> timestamp)
@ -48,46 +45,42 @@ public class SignalServiceCallMessage {
this.hangupMessage = hangupMessage;
this.busyMessage = busyMessage;
this.opaqueMessage = opaqueMessage;
this.isMultiRing = isMultiRing;
this.destinationDeviceId = destinationDeviceId;
this.groupId = groupId;
this.timestamp = timestamp;
}
public static SignalServiceCallMessage forOffer(OfferMessage offerMessage, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forOffer(OfferMessage offerMessage, Integer destinationDeviceId) {
return new SignalServiceCallMessage(Optional.of(offerMessage),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
isMultiRing,
Optional.ofNullable(destinationDeviceId));
}
public static SignalServiceCallMessage forAnswer(AnswerMessage answerMessage, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forAnswer(AnswerMessage answerMessage, Integer destinationDeviceId) {
return new SignalServiceCallMessage(Optional.empty(),
Optional.of(answerMessage),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
isMultiRing,
Optional.ofNullable(destinationDeviceId));
}
public static SignalServiceCallMessage forIceUpdates(List<IceUpdateMessage> iceUpdateMessages, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forIceUpdates(List<IceUpdateMessage> iceUpdateMessages, Integer destinationDeviceId) {
return new SignalServiceCallMessage(Optional.empty(),
Optional.empty(),
Optional.of(iceUpdateMessages),
Optional.empty(),
Optional.empty(),
Optional.empty(),
isMultiRing,
Optional.ofNullable(destinationDeviceId));
}
public static SignalServiceCallMessage forIceUpdate(final IceUpdateMessage iceUpdateMessage, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forIceUpdate(final IceUpdateMessage iceUpdateMessage, Integer destinationDeviceId) {
List<IceUpdateMessage> iceUpdateMessages = new LinkedList<>();
iceUpdateMessages.add(iceUpdateMessage);
@ -97,51 +90,46 @@ public class SignalServiceCallMessage {
Optional.empty(),
Optional.empty(),
Optional.empty(),
isMultiRing,
Optional.ofNullable(destinationDeviceId));
}
public static SignalServiceCallMessage forHangup(HangupMessage hangupMessage, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forHangup(HangupMessage hangupMessage, Integer destinationDeviceId) {
return new SignalServiceCallMessage(Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.of(hangupMessage),
Optional.empty(),
Optional.empty(),
isMultiRing,
Optional.ofNullable(destinationDeviceId));
}
public static SignalServiceCallMessage forBusy(BusyMessage busyMessage, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forBusy(BusyMessage busyMessage, Integer destinationDeviceId) {
return new SignalServiceCallMessage(Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.of(busyMessage),
Optional.empty(),
isMultiRing,
Optional.ofNullable(destinationDeviceId));
}
public static SignalServiceCallMessage forOpaque(OpaqueMessage opaqueMessage, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forOpaque(OpaqueMessage opaqueMessage, Integer destinationDeviceId) {
return new SignalServiceCallMessage(Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.of(opaqueMessage),
isMultiRing,
Optional.ofNullable(destinationDeviceId));
}
public static SignalServiceCallMessage forOutgoingGroupOpaque(byte[] groupId, long timestamp, OpaqueMessage opaqueMessage, boolean isMultiRing, Integer destinationDeviceId) {
public static SignalServiceCallMessage forOutgoingGroupOpaque(byte[] groupId, long timestamp, OpaqueMessage opaqueMessage, Integer destinationDeviceId) {
return new SignalServiceCallMessage(Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.of(opaqueMessage),
isMultiRing,
Optional.ofNullable(destinationDeviceId),
Optional.of(groupId),
Optional.of(timestamp));
@ -155,7 +143,6 @@ public class SignalServiceCallMessage {
Optional.empty(),
Optional.empty(),
Optional.empty(),
false,
Optional.empty());
}
@ -183,10 +170,6 @@ public class SignalServiceCallMessage {
return opaqueMessage;
}
public boolean isMultiRing() {
return isMultiRing;
}
public Optional<Integer> getDestinationDeviceId() {
return destinationDeviceId;
}

View file

@ -63,27 +63,22 @@ message CallMessage {
}
optional uint64 id = 1;
// Legacy/deprecated; replaced by 'opaque'
optional string sdp = 2;
reserved /* sdp */ 2;
optional Type type = 3;
optional bytes opaque = 4;
}
message Answer {
optional uint64 id = 1;
// Legacy/deprecated; replaced by 'opaque'
optional string sdp = 2;
reserved /* sdp */ 2;
optional bytes opaque = 3;
}
message IceUpdate {
optional uint64 id = 1;
// Legacy/deprecated; remove when old clients are gone.
optional string mid = 2;
// Legacy/deprecated; remove when old clients are gone.
optional uint32 line = 3;
// Legacy/deprecated; replaced by 'opaque'
optional string sdp = 4;
reserved /* mid */ 2;
reserved /* line */ 3;
reserved /* sdp */ 4;
optional bytes opaque = 5;
}
@ -118,7 +113,7 @@ message CallMessage {
optional Offer offer = 1;
optional Answer answer = 2;
repeated IceUpdate iceUpdate = 3;
optional Hangup legacyHangup = 4;
reserved /* legacyHangup */ 4;
optional Busy busy = 5;
reserved /* profileKey */ 6;
optional Hangup hangup = 7;