org.whispersystems.signalservice.api.messages.calls.HangupMessage Java Examples
The following examples show how to use
org.whispersystems.signalservice.api.messages.calls.HangupMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebRtcCallService.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void handleSendHangup(Intent intent) { RemotePeer remotePeer = getRemotePeer(intent); CallId callId = getCallId(intent); Integer remoteDevice = intent.getIntExtra(EXTRA_REMOTE_DEVICE, -1); boolean broadcast = intent.getBooleanExtra(EXTRA_BROADCAST, false); HangupMessage.Type type = HangupMessage.Type.fromCode(intent.getStringExtra(EXTRA_HANGUP_TYPE)); boolean isLegacy = intent.getBooleanExtra(EXTRA_HANGUP_IS_LEGACY, true); int deviceId = intent.getIntExtra(EXTRA_HANGUP_DEVICE_ID, 0); Log.i(TAG, "handleSendHangup: id: " + callId.format(remoteDevice)); HangupMessage hangupMessage = new HangupMessage(callId.longValue(), type, deviceId, isLegacy); Integer destinationDeviceId = broadcast ? null : remoteDevice; SignalServiceCallMessage callMessage = SignalServiceCallMessage.forHangup(hangupMessage, true, destinationDeviceId); sendCallMessage(remotePeer, callMessage); }
Example #2
Source File: PushProcessMessageJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void handleCallHangupMessage(@NonNull SignalServiceContent content, @NonNull HangupMessage message, @NonNull Optional<Long> smsMessageId) { Log.i(TAG, "handleCallHangupMessage"); if (smsMessageId.isPresent()) { DatabaseFactory.getSmsDatabase(context).markAsMissedCall(smsMessageId.get()); } else { Intent intent = new Intent(context, WebRtcCallService.class); RemotePeer remotePeer = new RemotePeer(Recipient.externalPush(context, content.getSender()).getId()); intent.setAction(WebRtcCallService.ACTION_RECEIVE_HANGUP) .putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId()) .putExtra(WebRtcCallService.EXTRA_REMOTE_PEER, remotePeer) .putExtra(WebRtcCallService.EXTRA_REMOTE_DEVICE, content.getSenderDevice()) .putExtra(WebRtcCallService.EXTRA_HANGUP_IS_LEGACY, message.isLegacy()) .putExtra(WebRtcCallService.EXTRA_HANGUP_DEVICE_ID, message.getDeviceId()) .putExtra(WebRtcCallService.EXTRA_HANGUP_TYPE, message.getType().getCode()); context.startService(intent); } }
Example #3
Source File: WebRtcCallView.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public void setStatusFromHangupType(@NonNull HangupMessage.Type hangupType) { switch (hangupType) { case NORMAL: status.setText(R.string.RedPhone_ending_call); break; case ACCEPTED: status.setText(R.string.WebRtcCallActivity__answered_on_a_linked_device); break; case DECLINED: status.setText(R.string.WebRtcCallActivity__declined_on_a_linked_device); break; case BUSY: status.setText(R.string.WebRtcCallActivity__busy_on_a_linked_device); break; default: throw new IllegalStateException("Unknown hangup type: " + hangupType); } }
Example #4
Source File: WebRtcCallService.java From bcm-android with GNU General Public License v3.0 | 6 votes |
private void handleLocalHangup(Intent intent) { CallState currentState = this.callState.get(); ALog.i(TAG, "handleLocalHangup: " + currentState); if (WebRtcCallService.accountContext == null || !WebRtcCallService.accountContext.equals(getAccountContextFromIntent(intent))) { ALog.w(TAG, "Account context is null or not equals to the intent's one"); return; } if (this.dataChannel != null && this.recipient != null && this.callId != -1L) { this.dataChannel.send(new DataChannel.Buffer(ByteBuffer.wrap(Data.newBuilder().setHangup(Hangup.newBuilder().setId(this.callId)).build().toByteArray()), false)); sendMessage(WebRtcCallService.accountContext, this.recipient, SignalServiceCallMessage.forHangup(new HangupMessage(this.callId))); } if (recipient != null) { sendMessage(WebRtcViewModel.State.CALL_DISCONNECTED, this.recipient, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled); if (currentState != CallState.STATE_IDLE && currentState != CallState.STATE_CONNECTED) { insertMissedCallFromHangup(WebRtcCallService.accountContext, this.recipient, false); } } terminate(); }
Example #5
Source File: SignalServiceCipher.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private SignalServiceCallMessage createCallMessage(CallMessage content) { if (content.hasOffer()) { CallMessage.Offer offerContent = content.getOffer(); return SignalServiceCallMessage.forOffer(new OfferMessage(offerContent.getId(), offerContent.getDescription())); } else if (content.hasAnswer()) { CallMessage.Answer answerContent = content.getAnswer(); return SignalServiceCallMessage.forAnswer(new AnswerMessage(answerContent.getId(), answerContent.getDescription())); } else if (content.getIceUpdateCount() > 0) { List<IceUpdateMessage> iceUpdates = new LinkedList<>(); for (CallMessage.IceUpdate iceUpdate : content.getIceUpdateList()) { iceUpdates.add(new IceUpdateMessage(iceUpdate.getId(), iceUpdate.getSdpMid(), iceUpdate.getSdpMLineIndex(), iceUpdate.getSdp())); } return SignalServiceCallMessage.forIceUpdates(iceUpdates); } else if (content.hasHangup()) { CallMessage.Hangup hangup = content.getHangup(); return SignalServiceCallMessage.forHangup(new HangupMessage(hangup.getId())); } else if (content.hasBusy()) { CallMessage.Busy busy = content.getBusy(); return SignalServiceCallMessage.forBusy(new BusyMessage(busy.getId())); } return SignalServiceCallMessage.empty(); }
Example #6
Source File: WebRtcCallService.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void handleReceivedHangup(Intent intent) { CallId callId = getCallId(intent); Integer remoteDevice = intent.getIntExtra(EXTRA_REMOTE_DEVICE, -1); HangupMessage.Type hangupType = HangupMessage.Type.fromCode(intent.getStringExtra(EXTRA_HANGUP_TYPE)); Integer deviceId = intent.getIntExtra(EXTRA_HANGUP_DEVICE_ID, 0); CallManager.HangupType callHangupType = getCallHangupTypeFromHangupType(hangupType); Log.i(TAG, "handleReceivedHangup(): id: " + callId.format(remoteDevice)); try { callManager.receivedHangup(callId, remoteDevice, callHangupType, deviceId); } catch (CallException e) { callFailure("receivedHangup() failed: ", e); } }
Example #7
Source File: WebRtcCallService.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static @NonNull CallManager.HangupType getCallHangupTypeFromHangupType(@NonNull HangupMessage.Type hangupType) { switch (hangupType) { case ACCEPTED: return CallManager.HangupType.ACCEPTED; case BUSY: return CallManager.HangupType.BUSY; case NORMAL: return CallManager.HangupType.NORMAL; case DECLINED: return CallManager.HangupType.DECLINED; default: throw new IllegalArgumentException("Unexpected hangup type: " + hangupType); } }
Example #8
Source File: WebRtcCallService.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static @NonNull HangupMessage.Type getHangupTypeFromCallHangupType(@NonNull CallManager.HangupType hangupType) { switch (hangupType) { case ACCEPTED: return HangupMessage.Type.ACCEPTED; case BUSY: return HangupMessage.Type.BUSY; case NORMAL: return HangupMessage.Type.NORMAL; case DECLINED: return HangupMessage.Type.DECLINED; default: throw new IllegalArgumentException("Unexpected hangup type: " + hangupType); } }
Example #9
Source File: WebRtcCallActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void handleUntrustedIdentity(@NonNull WebRtcViewModel event) { final IdentityKey theirKey = event.getIdentityKey(); final Recipient recipient = event.getRecipient(); if (theirKey == null) { handleTerminate(recipient, HangupMessage.Type.NORMAL); } String name = recipient.getDisplayName(this); String introduction = getString(R.string.WebRtcCallScreen_new_safety_numbers, name, name); SpannableString spannableString = new SpannableString(introduction + " " + getString(R.string.WebRtcCallScreen_you_may_wish_to_verify_this_contact)); spannableString.setSpan(new VerifySpan(this, recipient.getId(), theirKey), introduction.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); AppCompatTextView untrustedIdentityExplanation = new AppCompatTextView(this); untrustedIdentityExplanation.setText(spannableString); untrustedIdentityExplanation.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(this) .setView(untrustedIdentityExplanation) .setPositiveButton(R.string.WebRtcCallScreen_accept, (d, w) -> { synchronized (SESSION_LOCK) { TextSecureIdentityKeyStore identityKeyStore = new TextSecureIdentityKeyStore(WebRtcCallActivity.this); identityKeyStore.saveIdentity(new SignalProtocolAddress(recipient.requireServiceId(), 1), theirKey, true); } d.dismiss(); Intent intent = new Intent(WebRtcCallActivity.this, WebRtcCallService.class); intent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL) .putExtra(WebRtcCallService.EXTRA_REMOTE_PEER, new RemotePeer(recipient.getId())); startService(intent); }) .setNegativeButton(R.string.WebRtcCallScreen_end_call, (d, w) -> { d.dismiss(); handleTerminate(recipient, HangupMessage.Type.NORMAL); }) .show(); }
Example #10
Source File: WebRtcCallActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventMainThread(final WebRtcViewModel event) { Log.i(TAG, "Got message from service: " + event); viewModel.setRecipient(event.getRecipient()); switch (event.getState()) { case CALL_CONNECTED: handleCallConnected(event); break; case NETWORK_FAILURE: handleServerFailure(event); break; case CALL_RINGING: handleCallRinging(event); break; case CALL_DISCONNECTED: handleTerminate(event.getRecipient(), HangupMessage.Type.NORMAL); break; case CALL_ACCEPTED_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.ACCEPTED); break; case CALL_DECLINED_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.DECLINED); break; case CALL_ONGOING_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.BUSY); break; case NO_SUCH_USER: handleNoSuchUser(event); break; case RECIPIENT_UNAVAILABLE: handleRecipientUnavailable(event); break; case CALL_INCOMING: handleIncomingCall(event); break; case CALL_OUTGOING: handleOutgoingCall(event); break; case CALL_BUSY: handleCallBusy(event); break; case UNTRUSTED_IDENTITY: handleUntrustedIdentity(event); break; } callScreen.setLocalRenderer(event.getLocalRenderer()); callScreen.setRemoteRenderer(event.getRemoteRenderer()); viewModel.updateFromWebRtcViewModel(event); if (event.getLocalCameraState().getCameraCount() > 0 && enableVideoIfAvailable) { enableVideoIfAvailable = false; handleSetMuteVideo(false); } }
Example #11
Source File: SignalServiceCipher.java From bcm-android with GNU General Public License v3.0 | 5 votes |
private SignalServiceCallMessage createCallMessage(CallMessage content) { if (content.hasOffer()) { CallMessage.Offer offerContent = content.getOffer(); CallMessage.Offer.CallType callType = CallMessage.Offer.CallType.AUDIO; if (offerContent.hasType()) { callType = offerContent.getType(); } return SignalServiceCallMessage.forOffer(new OfferMessage(offerContent.getId(), offerContent.getDescription(), callType)); } else if (content.hasAnswer()) { CallMessage.Answer answerContent = content.getAnswer(); return SignalServiceCallMessage.forAnswer(new AnswerMessage(answerContent.getId(), answerContent.getDescription())); } else if (content.getIceUpdateCount() > 0) { List<IceUpdateMessage> iceUpdates = new LinkedList<>(); for (CallMessage.IceUpdate iceUpdate : content.getIceUpdateList()) { iceUpdates.add(new IceUpdateMessage(iceUpdate.getId(), iceUpdate.getSdpMid(), iceUpdate.getSdpMLineIndex(), iceUpdate.getSdp())); } return SignalServiceCallMessage.forIceUpdates(iceUpdates); } else if (content.hasHangup()) { CallMessage.Hangup hangup = content.getHangup(); return SignalServiceCallMessage.forHangup(new HangupMessage(hangup.getId())); } else if (content.hasBusy()) { CallMessage.Busy busy = content.getBusy(); return SignalServiceCallMessage.forBusy(new BusyMessage(busy.getId())); } return SignalServiceCallMessage.empty(); }
Example #12
Source File: PushDecryptJob.java From bcm-android with GNU General Public License v3.0 | 5 votes |
private void handleCallHangupMessage(@NonNull SignalServiceProtos.Envelope envelope, @NonNull HangupMessage message) { ALog.i(TAG, "handleCallHangupMessage"); try { Intent intent = new Intent(context, WebRtcCallService.class); intent.setAction(WebRtcCallService.ACTION_REMOTE_HANGUP); intent.putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId()); intent.putExtra(WebRtcCallService.EXTRA_REMOTE_ADDRESS, Address.from(accountContext, envelope.getSource())); intent.putExtra(ARouterConstants.PARAM.PARAM_ACCOUNT_CONTEXT, accountContext); AppUtilKotlinKt.startForegroundServiceCompat(context, intent); } catch (Exception ex) { ALog.e(TAG, "handleCallHangupMessage error", ex); } }
Example #13
Source File: WebRtcCallService.java From bcm-android with GNU General Public License v3.0 | 5 votes |
private void handleDenyCall(Intent intent) { try { CallState currentState = this.callState.get(); if (currentState != CallState.STATE_LOCAL_RINGING) { ALog.w(TAG, "handleDenyCall fail, current state is not local ringing"); return; } if (recipient == null || callId == -1L || dataChannel == null || WebRtcCallService.accountContext == null) { ALog.i(TAG, "handleDenyCall fail, recipient or callId or dataChannel is null"); return; } if (!WebRtcCallService.accountContext.equals(getAccountContextFromIntent(intent))) { ALog.w(TAG, "Not current major user."); return; } this.dataChannel.send(new DataChannel.Buffer(ByteBuffer.wrap(Data.newBuilder().setHangup(Hangup.newBuilder().setId(this.callId)).build().toByteArray()), false)); sendMessage(WebRtcCallService.accountContext, recipient, SignalServiceCallMessage.forHangup(new HangupMessage(this.callId))); if (currentState != CallState.STATE_IDLE && currentState != CallState.STATE_CONNECTED) { insertMissedCallFromHangup(WebRtcCallService.accountContext, this.recipient, true); } } finally { this.terminate(); } }
Example #14
Source File: WebRtcCallService.java From bcm-android with GNU General Public License v3.0 | 5 votes |
private ListenableFutureTask<Boolean> sendMessage(@NonNull AccountContext accountContext, @NonNull final Recipient recipient, @NonNull final SignalServiceCallMessage callMessage) { ALog.i(TAG, "Send message"); if (recipient.getAddress().toString().equals(accountContext.getUid())) { // Don't send call message to major ALog.w(TAG, "Recipient is not the same"); return null; } ListenableFutureTask<Boolean> listenableFutureTask = new ListenableFutureTask<>(() -> { ThreadRepo threadRepo = Repository.getInstance(accountContext).getThreadRepo(); long threadId = threadRepo.getThreadIdIfExist(recipient); BcmChatCore.INSTANCE.sendCallMessage(accountContext, threadId, new SignalServiceAddress(recipient.getAddress().serialize()), callMessage); return true; }, null, serviceExecutor); Optional<BusyMessage> busyMessageOptional = callMessage.getBusyMessage(); if (busyMessageOptional.isPresent()) { insertMissedCall(accountContext, recipient, NOTIFICATION_SIMPLY); } Optional<HangupMessage> hangupMessageOptional = callMessage.getHangupMessage(); if (hangupMessageOptional.isPresent()) { EventBus.getDefault().postSticky(new WebRtcViewModel(WebRtcViewModel.State.CALL_DISCONNECTED, videoCall, recipient, localCameraState, localRenderer, remoteRenderer, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled)); } networkExecutor.execute(listenableFutureTask); return listenableFutureTask; }
Example #15
Source File: WebRtcCallActivity.java From mollyim-android with GNU General Public License v3.0 | 3 votes |
private void handleTerminate(@NonNull Recipient recipient, @NonNull HangupMessage.Type hangupType) { Log.i(TAG, "handleTerminate called: " + hangupType.name()); callScreen.setRecipient(recipient); callScreen.setStatusFromHangupType(hangupType); EventBus.getDefault().removeStickyEvent(WebRtcViewModel.class); delayedFinish(); }