Search in sources :

Example 51 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class SignalCallManager method onSendHttpRequest.

@Override
public void onSendHttpRequest(long requestId, @NonNull String url, @NonNull CallManager.HttpMethod httpMethod, @Nullable List<HttpHeader> headers, @Nullable byte[] body) {
    if (callManager == null) {
        Log.w(TAG, "Unable to send http request, call manager is not initialized");
        return;
    }
    Log.i(TAG, "onSendHttpRequest(): request_id: " + requestId);
    networkExecutor.execute(() -> {
        List<Pair<String, String>> headerPairs;
        if (headers != null) {
            headerPairs = Stream.of(headers).map(header -> new Pair<>(header.getName(), header.getValue())).toList();
        } else {
            headerPairs = Collections.emptyList();
        }
        CallingResponse response = messageSender.makeCallingRequest(requestId, url, httpMethod.name(), headerPairs, body);
        try {
            if (response instanceof CallingResponse.Success) {
                CallingResponse.Success success = (CallingResponse.Success) response;
                callManager.receivedHttpResponse(requestId, success.getResponseStatus(), success.getResponseBody());
            } else {
                callManager.httpRequestFailed(requestId);
            }
        } catch (CallException e) {
            Log.i(TAG, "Failed to process HTTP response/failure", e);
        }
    });
}
Also used : CallingResponse(org.whispersystems.signalservice.api.messages.calls.CallingResponse) CallException(org.signal.ringrtc.CallException) Pair(org.whispersystems.libsignal.util.Pair)

Example 52 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class SignalCallManager method process.

private void process(@NonNull ProcessAction action) {
    Throwable t = new Throwable();
    String caller = t.getStackTrace().length > 1 ? t.getStackTrace()[1].getMethodName() : "unknown";
    if (callManager == null) {
        Log.w(TAG, "Unable to process action, call manager is not initialized");
        return;
    }
    serviceExecutor.execute(() -> {
        if (needsToSetSelfUuid) {
            try {
                callManager.setSelfUuid(Recipient.self().requireServiceId().uuid());
                needsToSetSelfUuid = false;
            } catch (CallException e) {
                Log.w(TAG, "Unable to set self UUID on CallManager", e);
            }
        }
        Log.v(TAG, "Processing action: " + caller + ", handler: " + serviceState.getActionProcessor().getTag());
        WebRtcServiceState previous = serviceState;
        serviceState = action.process(previous, previous.getActionProcessor());
        if (previous != serviceState) {
            if (serviceState.getCallInfoState().getCallState() != WebRtcViewModel.State.IDLE) {
                postStateUpdate(serviceState);
            }
        }
    });
}
Also used : CallException(org.signal.ringrtc.CallException) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState)

Example 53 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class GroupConnectedActionProcessor method handleLocalHangup.

@Override
@NonNull
protected WebRtcServiceState handleLocalHangup(@NonNull WebRtcServiceState currentState) {
    Log.i(TAG, "handleLocalHangup():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    String eraId = WebRtcUtil.getGroupCallEraId(groupCall);
    webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId);
    List<UUID> members = Stream.of(currentState.getCallInfoState().getRemoteCallParticipants()).map(p -> p.getRecipient().requireServiceId().uuid()).toList();
    webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, false);
    currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
    webRtcInteractor.postStateUpdate(currentState);
    return terminateGroupCall(currentState);
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) UUID(java.util.UUID) CallException(org.signal.ringrtc.CallException) ArrayList(java.util.ArrayList) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) PeekInfo(org.signal.ringrtc.PeekInfo) Recipient(org.thoughtcrime.securesms.recipients.Recipient) ResultReceiver(android.os.ResultReceiver) Camera(org.thoughtcrime.securesms.ringrtc.Camera) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) UUID(java.util.UUID) NonNull(androidx.annotation.NonNull)

Example 54 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class IdleActionProcessor method handleGroupCallRingUpdate.

@Override
@NonNull
protected WebRtcServiceState handleGroupCallRingUpdate(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeerGroup, @NonNull GroupId.V2 groupId, long ringId, @NonNull UUID uuid, @NonNull CallManager.RingUpdate ringUpdate) {
    Log.i(TAG, "handleGroupCallRingUpdate(): recipient: " + remotePeerGroup.getId() + " ring: " + ringId + " update: " + ringUpdate);
    if (ringUpdate != CallManager.RingUpdate.REQUESTED) {
        SignalDatabase.groupCallRings().insertOrUpdateGroupRing(ringId, System.currentTimeMillis(), ringUpdate);
        return currentState;
    } else if (SignalDatabase.groupCallRings().isCancelled(ringId)) {
        try {
            Log.i(TAG, "Incoming ring request for already cancelled ring: " + ringId);
            webRtcInteractor.getCallManager().cancelGroupRing(groupId.getDecodedId(), ringId, null);
        } catch (CallException e) {
            Log.w(TAG, "Error while trying to cancel ring: " + ringId, e);
        }
        return currentState;
    }
    NotificationProfile activeProfile = NotificationProfiles.getActiveProfile(SignalDatabase.notificationProfiles().getProfiles());
    if (activeProfile != null && !(activeProfile.isRecipientAllowed(remotePeerGroup.getId()) || activeProfile.getAllowAllCalls())) {
        try {
            Log.i(TAG, "Incoming ring request for profile restricted recipient");
            SignalDatabase.groupCallRings().insertOrUpdateGroupRing(ringId, System.currentTimeMillis(), CallManager.RingUpdate.EXPIRED_REQUEST);
            webRtcInteractor.getCallManager().cancelGroupRing(groupId.getDecodedId(), ringId, CallManager.RingCancelReason.DeclinedByUser);
        } catch (CallException e) {
            Log.w(TAG, "Error while trying to cancel ring: " + ringId, e);
        }
        return currentState;
    }
    webRtcInteractor.peekGroupCallForRingingCheck(new GroupCallRingCheckInfo(remotePeerGroup.getId(), groupId, ringId, uuid, ringUpdate));
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) NotificationProfile(org.thoughtcrime.securesms.notifications.profiles.NotificationProfile) NonNull(androidx.annotation.NonNull)

Example 55 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class IdleActionProcessor method handleReceivedGroupCallPeekForRingingCheck.

@Override
@NonNull
protected WebRtcServiceState handleReceivedGroupCallPeekForRingingCheck(@NonNull WebRtcServiceState currentState, @NonNull GroupCallRingCheckInfo info, long deviceCount) {
    Log.i(tag, "handleReceivedGroupCallPeekForRingingCheck(): recipient: " + info.getRecipientId() + " ring: " + info.getRingId() + " deviceCount: " + deviceCount);
    if (SignalDatabase.groupCallRings().isCancelled(info.getRingId())) {
        try {
            Log.i(TAG, "Ring was cancelled while getting peek info ring: " + info.getRingId());
            webRtcInteractor.getCallManager().cancelGroupRing(info.getGroupId().getDecodedId(), info.getRingId(), null);
        } catch (CallException e) {
            Log.w(TAG, "Error while trying to cancel ring: " + info.getRingId(), e);
        }
        return currentState;
    }
    if (deviceCount == 0) {
        Log.i(TAG, "No one in the group call, mark as expired and do not ring");
        SignalDatabase.groupCallRings().insertOrUpdateGroupRing(info.getRingId(), System.currentTimeMillis(), CallManager.RingUpdate.EXPIRED_REQUEST);
        return currentState;
    }
    currentState = currentState.builder().actionProcessor(new IncomingGroupCallActionProcessor(webRtcInteractor)).build();
    return currentState.getActionProcessor().handleGroupCallRingUpdate(currentState, new RemotePeer(info.getRecipientId()), info.getGroupId(), info.getRingId(), info.getRingerUuid(), info.getRingUpdate());
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Aggregations

CallException (org.signal.ringrtc.CallException)70 NonNull (androidx.annotation.NonNull)62 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)36 GroupCall (org.signal.ringrtc.GroupCall)34 Recipient (org.thoughtcrime.securesms.recipients.Recipient)16 WebRtcServiceState (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState)12 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)10 Stream (com.annimon.stream.Stream)8 List (java.util.List)8 Log (org.signal.core.util.logging.Log)8 WebRtcViewModel (org.thoughtcrime.securesms.events.WebRtcViewModel)8 VideoState (org.thoughtcrime.securesms.service.webrtc.state.VideoState)8 ResultReceiver (android.os.ResultReceiver)6 Nullable (androidx.annotation.Nullable)6 Collection (java.util.Collection)6 Collections (java.util.Collections)6 Set (java.util.Set)6 UUID (java.util.UUID)6 CallManager (org.signal.ringrtc.CallManager)6 GroupManager (org.thoughtcrime.securesms.groups.GroupManager)6