Search in sources :

Example 16 with SignalServiceCallMessage

use of org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage in project Signal-Android by WhisperSystems.

the class MessageContentProcessor method handleMessage.

private void handleMessage(@NonNull SignalServiceContent content, long timestamp, @NonNull Recipient senderRecipient, @NonNull Optional<Long> smsMessageId) throws IOException, GroupChangeBusyException {
    try {
        Recipient threadRecipient = getMessageDestination(content);
        if (shouldIgnore(content, senderRecipient, threadRecipient)) {
            log(content.getTimestamp(), "Ignoring message.");
            return;
        }
        PendingRetryReceiptModel pending = ApplicationDependencies.getPendingRetryReceiptCache().get(senderRecipient.getId(), content.getTimestamp());
        long receivedTime = handlePendingRetry(pending, content, threadRecipient);
        log(String.valueOf(content.getTimestamp()), "Beginning message processing. Sender: " + formatSender(senderRecipient, content));
        if (content.getDataMessage().isPresent()) {
            GroupDatabase groupDatabase = SignalDatabase.groups();
            SignalServiceDataMessage message = content.getDataMessage().get();
            boolean isMediaMessage = message.getAttachments().isPresent() || message.getQuote().isPresent() || message.getSharedContacts().isPresent() || message.getPreviews().isPresent() || message.getSticker().isPresent() || message.getMentions().isPresent();
            Optional<GroupId> groupId = GroupUtil.idFromGroupContext(message.getGroupContext());
            boolean isGv2Message = groupId.isPresent() && groupId.get().isV2();
            if (isGv2Message) {
                if (handleGv2PreProcessing(groupId.orNull().requireV2(), content, content.getDataMessage().get().getGroupContext().get().getGroupV2().get(), senderRecipient)) {
                    return;
                }
            }
            MessageId messageId = null;
            if (isInvalidMessage(message))
                handleInvalidMessage(content.getSender(), content.getSenderDevice(), groupId, content.getTimestamp(), smsMessageId);
            else if (message.isEndSession())
                messageId = handleEndSessionMessage(content, smsMessageId, senderRecipient);
            else if (message.isGroupV1Update())
                handleGroupV1Message(content, message, smsMessageId, groupId.get().requireV1(), senderRecipient, threadRecipient, receivedTime);
            else if (message.isExpirationUpdate())
                messageId = handleExpirationUpdate(content, message, smsMessageId, groupId, senderRecipient, threadRecipient, receivedTime);
            else if (message.getReaction().isPresent())
                messageId = handleReaction(content, message, senderRecipient);
            else if (message.getRemoteDelete().isPresent())
                messageId = handleRemoteDelete(content, message, senderRecipient);
            else if (message.getPayment().isPresent())
                handlePayment(content, message, senderRecipient);
            else if (message.getStoryContext().isPresent())
                handleStoryMessage(content);
            else if (isMediaMessage)
                messageId = handleMediaMessage(content, message, smsMessageId, senderRecipient, threadRecipient, receivedTime);
            else if (message.getBody().isPresent())
                messageId = handleTextMessage(content, message, smsMessageId, groupId, senderRecipient, threadRecipient, receivedTime);
            else if (Build.VERSION.SDK_INT > 19 && message.getGroupCallUpdate().isPresent())
                handleGroupCallUpdateMessage(content, message, groupId, senderRecipient);
            if (groupId.isPresent() && groupDatabase.isUnknownGroup(groupId.get())) {
                handleUnknownGroupMessage(content, message.getGroupContext().get(), senderRecipient);
            }
            if (message.getProfileKey().isPresent()) {
                handleProfileKey(content, message.getProfileKey().get(), senderRecipient);
            }
            if (content.isNeedsReceipt() && messageId != null) {
                handleNeedsDeliveryReceipt(content, message, messageId);
            } else if (!content.isNeedsReceipt()) {
                if (RecipientUtil.shouldHaveProfileKey(context, threadRecipient)) {
                    Log.w(TAG, "Received an unsealed sender message from " + senderRecipient.getId() + ", but they should already have our profile key. Correcting.");
                    if (groupId.isPresent() && groupId.get().isV2()) {
                        Log.i(TAG, "Message was to a GV2 group. Ensuring our group profile keys are up to date.");
                        ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob(false)).then(GroupV2UpdateSelfProfileKeyJob.withQueueLimits(groupId.get().requireV2())).enqueue();
                    } else if (!threadRecipient.isGroup()) {
                        Log.i(TAG, "Message was to a 1:1. Ensuring this user has our profile key.");
                        ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob(false)).then(ProfileKeySendJob.create(context, SignalDatabase.threads().getOrCreateThreadIdFor(threadRecipient), true)).enqueue();
                    }
                }
            }
        } else if (content.getSyncMessage().isPresent()) {
            TextSecurePreferences.setMultiDevice(context, true);
            SignalServiceSyncMessage syncMessage = content.getSyncMessage().get();
            if (syncMessage.getSent().isPresent())
                handleSynchronizeSentMessage(content, syncMessage.getSent().get(), senderRecipient);
            else if (syncMessage.getRequest().isPresent())
                handleSynchronizeRequestMessage(syncMessage.getRequest().get(), content.getTimestamp());
            else if (syncMessage.getRead().isPresent())
                handleSynchronizeReadMessage(syncMessage.getRead().get(), content.getTimestamp(), senderRecipient);
            else if (syncMessage.getViewed().isPresent())
                handleSynchronizeViewedMessage(syncMessage.getViewed().get(), content.getTimestamp());
            else if (syncMessage.getViewOnceOpen().isPresent())
                handleSynchronizeViewOnceOpenMessage(syncMessage.getViewOnceOpen().get(), content.getTimestamp());
            else if (syncMessage.getVerified().isPresent())
                handleSynchronizeVerifiedMessage(syncMessage.getVerified().get());
            else if (syncMessage.getStickerPackOperations().isPresent())
                handleSynchronizeStickerPackOperation(syncMessage.getStickerPackOperations().get(), content.getTimestamp());
            else if (syncMessage.getConfiguration().isPresent())
                handleSynchronizeConfigurationMessage(syncMessage.getConfiguration().get(), content.getTimestamp());
            else if (syncMessage.getBlockedList().isPresent())
                handleSynchronizeBlockedListMessage(syncMessage.getBlockedList().get());
            else if (syncMessage.getFetchType().isPresent())
                handleSynchronizeFetchMessage(syncMessage.getFetchType().get(), content.getTimestamp());
            else if (syncMessage.getMessageRequestResponse().isPresent())
                handleSynchronizeMessageRequestResponse(syncMessage.getMessageRequestResponse().get(), content.getTimestamp());
            else if (syncMessage.getOutgoingPaymentMessage().isPresent())
                handleSynchronizeOutgoingPayment(content, syncMessage.getOutgoingPaymentMessage().get());
            else if (syncMessage.getKeys().isPresent())
                handleSynchronizeKeys(syncMessage.getKeys().get(), content.getTimestamp());
            else if (syncMessage.getContacts().isPresent())
                handleSynchronizeContacts(syncMessage.getContacts().get(), content.getTimestamp());
            else
                warn(String.valueOf(content.getTimestamp()), "Contains no known sync types...");
        } else if (content.getCallMessage().isPresent()) {
            log(String.valueOf(content.getTimestamp()), "Got call message...");
            SignalServiceCallMessage message = content.getCallMessage().get();
            Optional<Integer> destinationDeviceId = message.getDestinationDeviceId();
            if (destinationDeviceId.isPresent() && destinationDeviceId.get() != SignalStore.account().getDeviceId()) {
                log(String.valueOf(content.getTimestamp()), String.format(Locale.US, "Ignoring call message that is not for this device! intended: %d, this: %d", destinationDeviceId.get(), SignalStore.account().getDeviceId()));
                return;
            }
            if (message.getOfferMessage().isPresent())
                handleCallOfferMessage(content, message.getOfferMessage().get(), smsMessageId, senderRecipient);
            else if (message.getAnswerMessage().isPresent())
                handleCallAnswerMessage(content, message.getAnswerMessage().get(), senderRecipient);
            else if (message.getIceUpdateMessages().isPresent())
                handleCallIceUpdateMessage(content, message.getIceUpdateMessages().get(), senderRecipient);
            else if (message.getHangupMessage().isPresent())
                handleCallHangupMessage(content, message.getHangupMessage().get(), smsMessageId, senderRecipient);
            else if (message.getBusyMessage().isPresent())
                handleCallBusyMessage(content, message.getBusyMessage().get(), senderRecipient);
            else if (message.getOpaqueMessage().isPresent())
                handleCallOpaqueMessage(content, message.getOpaqueMessage().get(), senderRecipient);
        } else if (content.getReceiptMessage().isPresent()) {
            SignalServiceReceiptMessage message = content.getReceiptMessage().get();
            if (message.isReadReceipt())
                handleReadReceipt(content, message, senderRecipient);
            else if (message.isDeliveryReceipt())
                handleDeliveryReceipt(content, message, senderRecipient);
            else if (message.isViewedReceipt())
                handleViewedReceipt(content, message, senderRecipient);
        } else if (content.getTypingMessage().isPresent()) {
            handleTypingMessage(content, content.getTypingMessage().get(), senderRecipient);
        } else if (content.getDecryptionErrorMessage().isPresent()) {
            handleRetryReceipt(content, content.getDecryptionErrorMessage().get(), senderRecipient);
        } else if (content.getSenderKeyDistributionMessage().isPresent()) {
        // Already handled, here in order to prevent unrecognized message log
        } else {
            warn(String.valueOf(content.getTimestamp()), "Got unrecognized message!");
        }
        resetRecipientToPush(senderRecipient);
        if (pending != null) {
            warn(content.getTimestamp(), "Pending retry was processed. Deleting.");
            ApplicationDependencies.getPendingRetryReceiptCache().delete(pending);
        }
    } catch (StorageFailedException e) {
        warn(String.valueOf(content.getTimestamp()), e);
        handleCorruptMessage(e.getSender(), e.getSenderDevice(), timestamp, smsMessageId);
    } catch (BadGroupIdException e) {
        warn(String.valueOf(content.getTimestamp()), "Ignoring message with bad group id", e);
    }
}
Also used : PendingRetryReceiptModel(org.thoughtcrime.securesms.database.model.PendingRetryReceiptModel) SignalServiceReceiptMessage(org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SignalServiceSyncMessage(org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage) GroupId(org.thoughtcrime.securesms.groups.GroupId) SignalServiceDataMessage(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage) RefreshAttributesJob(org.thoughtcrime.securesms.jobs.RefreshAttributesJob) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) BadGroupIdException(org.thoughtcrime.securesms.groups.BadGroupIdException) MessageId(org.thoughtcrime.securesms.database.model.MessageId) SyncMessageId(org.thoughtcrime.securesms.database.MessageDatabase.SyncMessageId)

Example 17 with SignalServiceCallMessage

use of org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method createCallContent.

private Content createCallContent(SignalServiceCallMessage callMessage) {
    Content.Builder container = Content.newBuilder();
    CallMessage.Builder builder = CallMessage.newBuilder();
    if (callMessage.getOfferMessage().isPresent()) {
        OfferMessage offer = callMessage.getOfferMessage().get();
        CallMessage.Offer.Builder offerBuilder = CallMessage.Offer.newBuilder().setId(offer.getId()).setType(offer.getType().getProtoType());
        if (offer.getOpaque() != null) {
            offerBuilder.setOpaque(ByteString.copyFrom(offer.getOpaque()));
        }
        if (offer.getSdp() != null) {
            offerBuilder.setSdp(offer.getSdp());
        }
        builder.setOffer(offerBuilder);
    } else if (callMessage.getAnswerMessage().isPresent()) {
        AnswerMessage answer = callMessage.getAnswerMessage().get();
        CallMessage.Answer.Builder answerBuilder = CallMessage.Answer.newBuilder().setId(answer.getId());
        if (answer.getOpaque() != null) {
            answerBuilder.setOpaque(ByteString.copyFrom(answer.getOpaque()));
        }
        if (answer.getSdp() != null) {
            answerBuilder.setSdp(answer.getSdp());
        }
        builder.setAnswer(answerBuilder);
    } else if (callMessage.getIceUpdateMessages().isPresent()) {
        List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get();
        for (IceUpdateMessage update : updates) {
            CallMessage.IceUpdate.Builder iceBuilder = CallMessage.IceUpdate.newBuilder().setId(update.getId()).setMid("audio").setLine(0);
            if (update.getOpaque() != null) {
                iceBuilder.setOpaque(ByteString.copyFrom(update.getOpaque()));
            }
            if (update.getSdp() != null) {
                iceBuilder.setSdp(update.getSdp());
            }
            builder.addIceUpdate(iceBuilder);
        }
    } else if (callMessage.getHangupMessage().isPresent()) {
        CallMessage.Hangup.Type protoType = callMessage.getHangupMessage().get().getType().getProtoType();
        CallMessage.Hangup.Builder builderForHangup = CallMessage.Hangup.newBuilder().setType(protoType).setId(callMessage.getHangupMessage().get().getId());
        if (protoType != CallMessage.Hangup.Type.HANGUP_NORMAL) {
            builderForHangup.setDeviceId(callMessage.getHangupMessage().get().getDeviceId());
        }
        if (callMessage.getHangupMessage().get().isLegacy()) {
            builder.setLegacyHangup(builderForHangup);
        } else {
            builder.setHangup(builderForHangup);
        }
    } else if (callMessage.getBusyMessage().isPresent()) {
        builder.setBusy(CallMessage.Busy.newBuilder().setId(callMessage.getBusyMessage().get().getId()));
    } else if (callMessage.getOpaqueMessage().isPresent()) {
        OpaqueMessage opaqueMessage = callMessage.getOpaqueMessage().get();
        ByteString data = ByteString.copyFrom(opaqueMessage.getOpaque());
        CallMessage.Opaque.Urgency urgency = opaqueMessage.getUrgency().toProto();
        builder.setOpaque(CallMessage.Opaque.newBuilder().setData(data).setUrgency(urgency));
    }
    builder.setMultiRing(callMessage.isMultiRing());
    if (callMessage.getDestinationDeviceId().isPresent()) {
        builder.setDestinationDeviceId(callMessage.getDestinationDeviceId().get());
    }
    container.setCallMessage(builder);
    return container.build();
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) CallMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage) ByteString(com.google.protobuf.ByteString) SignalGroupSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalGroupSessionBuilder) GroupSessionBuilder(org.whispersystems.libsignal.groups.GroupSessionBuilder) SessionBuilder(org.whispersystems.libsignal.SessionBuilder) SignalSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalSessionBuilder) AnswerMessage(org.whispersystems.signalservice.api.messages.calls.AnswerMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)

Example 18 with SignalServiceCallMessage

use of org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage in project Signal-Android by signalapp.

the class SignalServiceMessageSender method createCallContent.

private Content createCallContent(SignalServiceCallMessage callMessage) {
    Content.Builder container = Content.newBuilder();
    CallMessage.Builder builder = CallMessage.newBuilder();
    if (callMessage.getOfferMessage().isPresent()) {
        OfferMessage offer = callMessage.getOfferMessage().get();
        CallMessage.Offer.Builder offerBuilder = CallMessage.Offer.newBuilder().setId(offer.getId()).setType(offer.getType().getProtoType());
        if (offer.getOpaque() != null) {
            offerBuilder.setOpaque(ByteString.copyFrom(offer.getOpaque()));
        }
        if (offer.getSdp() != null) {
            offerBuilder.setSdp(offer.getSdp());
        }
        builder.setOffer(offerBuilder);
    } else if (callMessage.getAnswerMessage().isPresent()) {
        AnswerMessage answer = callMessage.getAnswerMessage().get();
        CallMessage.Answer.Builder answerBuilder = CallMessage.Answer.newBuilder().setId(answer.getId());
        if (answer.getOpaque() != null) {
            answerBuilder.setOpaque(ByteString.copyFrom(answer.getOpaque()));
        }
        if (answer.getSdp() != null) {
            answerBuilder.setSdp(answer.getSdp());
        }
        builder.setAnswer(answerBuilder);
    } else if (callMessage.getIceUpdateMessages().isPresent()) {
        List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get();
        for (IceUpdateMessage update : updates) {
            CallMessage.IceUpdate.Builder iceBuilder = CallMessage.IceUpdate.newBuilder().setId(update.getId()).setMid("audio").setLine(0);
            if (update.getOpaque() != null) {
                iceBuilder.setOpaque(ByteString.copyFrom(update.getOpaque()));
            }
            if (update.getSdp() != null) {
                iceBuilder.setSdp(update.getSdp());
            }
            builder.addIceUpdate(iceBuilder);
        }
    } else if (callMessage.getHangupMessage().isPresent()) {
        CallMessage.Hangup.Type protoType = callMessage.getHangupMessage().get().getType().getProtoType();
        CallMessage.Hangup.Builder builderForHangup = CallMessage.Hangup.newBuilder().setType(protoType).setId(callMessage.getHangupMessage().get().getId());
        if (protoType != CallMessage.Hangup.Type.HANGUP_NORMAL) {
            builderForHangup.setDeviceId(callMessage.getHangupMessage().get().getDeviceId());
        }
        if (callMessage.getHangupMessage().get().isLegacy()) {
            builder.setLegacyHangup(builderForHangup);
        } else {
            builder.setHangup(builderForHangup);
        }
    } else if (callMessage.getBusyMessage().isPresent()) {
        builder.setBusy(CallMessage.Busy.newBuilder().setId(callMessage.getBusyMessage().get().getId()));
    } else if (callMessage.getOpaqueMessage().isPresent()) {
        OpaqueMessage opaqueMessage = callMessage.getOpaqueMessage().get();
        ByteString data = ByteString.copyFrom(opaqueMessage.getOpaque());
        CallMessage.Opaque.Urgency urgency = opaqueMessage.getUrgency().toProto();
        builder.setOpaque(CallMessage.Opaque.newBuilder().setData(data).setUrgency(urgency));
    }
    builder.setMultiRing(callMessage.isMultiRing());
    if (callMessage.getDestinationDeviceId().isPresent()) {
        builder.setDestinationDeviceId(callMessage.getDestinationDeviceId().get());
    }
    container.setCallMessage(builder);
    return container.build();
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) CallMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.CallMessage) ByteString(com.google.protobuf.ByteString) SignalGroupSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalGroupSessionBuilder) GroupSessionBuilder(org.whispersystems.libsignal.groups.GroupSessionBuilder) SessionBuilder(org.whispersystems.libsignal.SessionBuilder) SignalSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalSessionBuilder) AnswerMessage(org.whispersystems.signalservice.api.messages.calls.AnswerMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)

Example 19 with SignalServiceCallMessage

use of org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage in project Signal-Android by signalapp.

the class SignalCallManager method sendCallMessage.

public void sendCallMessage(@NonNull final RemotePeer remotePeer, @NonNull final SignalServiceCallMessage callMessage) {
    networkExecutor.execute(() -> {
        Recipient recipient = Recipient.resolved(remotePeer.getId());
        if (recipient.isBlocked()) {
            return;
        }
        try {
            messageSender.sendCallMessage(RecipientUtil.toSignalServiceAddress(context, recipient), UnidentifiedAccessUtil.getAccessFor(context, recipient), callMessage);
            process((s, p) -> p.handleMessageSentSuccess(s, remotePeer.getCallId()));
        } catch (UntrustedIdentityException e) {
            RetrieveProfileJob.enqueue(remotePeer.getId());
            processSendMessageFailureWithChangeDetection(remotePeer, (s, p) -> p.handleMessageSentError(s, remotePeer.getCallId(), UNTRUSTED_IDENTITY, Optional.fromNullable(e.getIdentityKey())));
        } catch (IOException e) {
            processSendMessageFailureWithChangeDetection(remotePeer, (s, p) -> p.handleMessageSentError(s, remotePeer.getCallId(), e instanceof UnregisteredUserException ? NO_SUCH_USER : NETWORK_FAILURE, Optional.absent()));
        }
    });
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SignalAudioManager(org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager) SignalServiceAccountManager(org.whispersystems.signalservice.api.SignalServiceAccountManager) NetworkRoute(org.signal.ringrtc.NetworkRoute) BubbleUtil(org.thoughtcrime.securesms.util.BubbleUtil) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) CallingResponse(org.whispersystems.signalservice.api.messages.calls.CallingResponse) TurnServerInfo(org.whispersystems.signalservice.api.messages.calls.TurnServerInfo) NonNull(androidx.annotation.NonNull) RecipientUtil(org.thoughtcrime.securesms.recipients.RecipientUtil) CallException(org.signal.ringrtc.CallException) WebRtcCallActivity(org.thoughtcrime.securesms.WebRtcCallActivity) CallManager(org.signal.ringrtc.CallManager) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) NetworkUtil(org.thoughtcrime.securesms.util.NetworkUtil) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IDLE(org.thoughtcrime.securesms.events.WebRtcViewModel.GroupCallState.IDLE) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) WebRtcUtil.getUrgencyFromCallUrgency(org.thoughtcrime.securesms.service.webrtc.WebRtcUtil.getUrgencyFromCallUrgency) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) ACI(org.whispersystems.signalservice.api.push.ACI) HttpHeader(org.signal.ringrtc.HttpHeader) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Collection(java.util.Collection) GroupCallUpdateSendJob(org.thoughtcrime.securesms.jobs.GroupCallUpdateSendJob) Set(java.util.Set) UnidentifiedAccessUtil(org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil) UUID(java.util.UUID) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) UNTRUSTED_IDENTITY(org.thoughtcrime.securesms.events.WebRtcViewModel.State.UNTRUSTED_IDENTITY) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) InvalidInputException(org.signal.zkgroup.InvalidInputException) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) Application(android.app.Application) GroupId(org.thoughtcrime.securesms.groups.GroupId) CallId(org.signal.ringrtc.CallId) CameraEventListener(org.thoughtcrime.securesms.ringrtc.CameraEventListener) Context(android.content.Context) RecipientAccessList(org.thoughtcrime.securesms.util.RecipientAccessList) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) Remote(org.signal.ringrtc.Remote) Util(org.thoughtcrime.securesms.util.Util) VerificationFailedException(org.signal.zkgroup.VerificationFailedException) Intent(android.content.Intent) AppForegroundObserver(org.thoughtcrime.securesms.util.AppForegroundObserver) RetrieveProfileJob(org.thoughtcrime.securesms.jobs.RetrieveProfileJob) NETWORK_FAILURE(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NETWORK_FAILURE) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) LockManager(org.thoughtcrime.securesms.webrtc.locks.LockManager) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) CameraState(org.thoughtcrime.securesms.ringrtc.CameraState) Pair(org.whispersystems.libsignal.util.Pair) EventBus(org.greenrobot.eventbus.EventBus) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) Build(android.os.Build) LinkedList(java.util.LinkedList) GroupSendUtil(org.thoughtcrime.securesms.messages.GroupSendUtil) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) ExecutorService(java.util.concurrent.ExecutorService) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) PeerConnection(org.webrtc.PeerConnection) Executor(java.util.concurrent.Executor) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) IOException(java.io.IOException) NO_SUCH_USER(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NO_SUCH_USER) GroupCallPeekEvent(org.thoughtcrime.securesms.events.GroupCallPeekEvent) Optional(org.whispersystems.libsignal.util.guava.Optional) UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) GroupIdentifier(org.signal.zkgroup.groups.GroupIdentifier) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) CALL_INCOMING(org.thoughtcrime.securesms.events.WebRtcViewModel.State.CALL_INCOMING) ResultReceiver(android.os.ResultReceiver) Collections(java.util.Collections) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IOException(java.io.IOException)

Example 20 with SignalServiceCallMessage

use of org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage in project Signal-Android by signalapp.

the class SignalCallManager method onSendCallMessage.

@Override
public void onSendCallMessage(@NonNull UUID uuid, @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(ACI.from(uuid), null));
        if (recipient.isBlocked()) {
            return;
        }
        try {
            messageSender.sendCallMessage(RecipientUtil.toSignalServiceAddress(context, recipient), recipient.isSelf() ? Optional.absent() : UnidentifiedAccessUtil.getAccessFor(context, recipient), callMessage);
        } catch (UntrustedIdentityException e) {
            Log.i(TAG, "sendOpaqueCallMessage onFailure: ", e);
            RetrieveProfileJob.enqueue(recipient.getId());
            process((s, p) -> p.handleGroupMessageSentError(s, Collections.singletonList(recipient.getId()), UNTRUSTED_IDENTITY));
        } catch (IOException e) {
            Log.i(TAG, "sendOpaqueCallMessage onFailure: ", e);
            process((s, p) -> p.handleGroupMessageSentError(s, Collections.singletonList(recipient.getId()), NETWORK_FAILURE));
        }
    });
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SignalAudioManager(org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager) SignalServiceAccountManager(org.whispersystems.signalservice.api.SignalServiceAccountManager) NetworkRoute(org.signal.ringrtc.NetworkRoute) BubbleUtil(org.thoughtcrime.securesms.util.BubbleUtil) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) CallingResponse(org.whispersystems.signalservice.api.messages.calls.CallingResponse) TurnServerInfo(org.whispersystems.signalservice.api.messages.calls.TurnServerInfo) NonNull(androidx.annotation.NonNull) RecipientUtil(org.thoughtcrime.securesms.recipients.RecipientUtil) CallException(org.signal.ringrtc.CallException) WebRtcCallActivity(org.thoughtcrime.securesms.WebRtcCallActivity) CallManager(org.signal.ringrtc.CallManager) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) NetworkUtil(org.thoughtcrime.securesms.util.NetworkUtil) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IDLE(org.thoughtcrime.securesms.events.WebRtcViewModel.GroupCallState.IDLE) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) WebRtcUtil.getUrgencyFromCallUrgency(org.thoughtcrime.securesms.service.webrtc.WebRtcUtil.getUrgencyFromCallUrgency) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) ACI(org.whispersystems.signalservice.api.push.ACI) HttpHeader(org.signal.ringrtc.HttpHeader) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Collection(java.util.Collection) GroupCallUpdateSendJob(org.thoughtcrime.securesms.jobs.GroupCallUpdateSendJob) Set(java.util.Set) UnidentifiedAccessUtil(org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil) UUID(java.util.UUID) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) UNTRUSTED_IDENTITY(org.thoughtcrime.securesms.events.WebRtcViewModel.State.UNTRUSTED_IDENTITY) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) InvalidInputException(org.signal.zkgroup.InvalidInputException) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) Application(android.app.Application) GroupId(org.thoughtcrime.securesms.groups.GroupId) CallId(org.signal.ringrtc.CallId) CameraEventListener(org.thoughtcrime.securesms.ringrtc.CameraEventListener) Context(android.content.Context) RecipientAccessList(org.thoughtcrime.securesms.util.RecipientAccessList) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) Remote(org.signal.ringrtc.Remote) Util(org.thoughtcrime.securesms.util.Util) VerificationFailedException(org.signal.zkgroup.VerificationFailedException) Intent(android.content.Intent) AppForegroundObserver(org.thoughtcrime.securesms.util.AppForegroundObserver) RetrieveProfileJob(org.thoughtcrime.securesms.jobs.RetrieveProfileJob) NETWORK_FAILURE(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NETWORK_FAILURE) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) LockManager(org.thoughtcrime.securesms.webrtc.locks.LockManager) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) CameraState(org.thoughtcrime.securesms.ringrtc.CameraState) Pair(org.whispersystems.libsignal.util.Pair) EventBus(org.greenrobot.eventbus.EventBus) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) Build(android.os.Build) LinkedList(java.util.LinkedList) GroupSendUtil(org.thoughtcrime.securesms.messages.GroupSendUtil) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) ExecutorService(java.util.concurrent.ExecutorService) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) PeerConnection(org.webrtc.PeerConnection) Executor(java.util.concurrent.Executor) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) IOException(java.io.IOException) NO_SUCH_USER(org.thoughtcrime.securesms.events.WebRtcViewModel.State.NO_SUCH_USER) GroupCallPeekEvent(org.thoughtcrime.securesms.events.GroupCallPeekEvent) Optional(org.whispersystems.libsignal.util.guava.Optional) UnregisteredUserException(org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException) GroupIdentifier(org.signal.zkgroup.groups.GroupIdentifier) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) CALL_INCOMING(org.thoughtcrime.securesms.events.WebRtcViewModel.State.CALL_INCOMING) ResultReceiver(android.os.ResultReceiver) Collections(java.util.Collections) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) SignalServiceCallMessage(org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IOException(java.io.IOException) OpaqueMessage(org.whispersystems.signalservice.api.messages.calls.OpaqueMessage)

Aggregations

SignalServiceCallMessage (org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage)25 NonNull (androidx.annotation.NonNull)16 OfferMessage (org.whispersystems.signalservice.api.messages.calls.OfferMessage)15 Recipient (org.thoughtcrime.securesms.recipients.Recipient)12 GroupDatabase (org.thoughtcrime.securesms.database.GroupDatabase)10 GroupId (org.thoughtcrime.securesms.groups.GroupId)10 AnswerMessage (org.whispersystems.signalservice.api.messages.calls.AnswerMessage)9 Context (android.content.Context)8 ResultReceiver (android.os.ResultReceiver)8 Nullable (androidx.annotation.Nullable)8 Stream (com.annimon.stream.Stream)8 Collection (java.util.Collection)8 LinkedList (java.util.LinkedList)8 List (java.util.List)8 Set (java.util.Set)8 UUID (java.util.UUID)8 Log (org.signal.core.util.logging.Log)8 CallException (org.signal.ringrtc.CallException)8 CallId (org.signal.ringrtc.CallId)8 CallManager (org.signal.ringrtc.CallManager)8