From 9544b994dc91948feaa45abe663134a37180a29a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 4 May 2021 17:52:17 +0200 Subject: [PATCH] invoke omemo trust/fetch activity when triggering phone call in require_verification mode --- .../java/eu/siacs/conversations/Config.java | 1 + .../ui/ConversationFragment.java | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 7f7662bd1..5286abf49 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -119,6 +119,7 @@ public final class Config { public static final boolean ENCRYPT_ON_HTTP_UPLOADED = false; public static final boolean X509_VERIFICATION = false; //use x509 certificates to verify OMEMO keys + public static final boolean REQUIRE_RTP_VERIFICATION = false; //require a/v calls to be verified with OMEMO public static final boolean ONLY_INTERNAL_STORAGE = false; //use internal storage instead of sdcard to save attachments diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 31105cac5..37d7024e0 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -734,7 +734,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (body.length() == 0 || conversation == null) { return; } - if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(REQUEST_TRUST_KEYS_TEXT)) { + if (trustKeysIfNeeded(conversation, REQUEST_TRUST_KEYS_TEXT)) { return; } final Message message; @@ -757,6 +757,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } + private boolean trustKeysIfNeeded(final Conversation conversation, final int requestCode) { + return conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(requestCode); + } + protected boolean trustKeysIfNeeded(int requestCode) { AxolotlService axolotlService = conversation.getAccount().getAxolotlService(); final List targets = axolotlService.getCryptoTargets(conversation); @@ -824,6 +828,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke case REQUEST_TRUST_KEYS_ATTACHMENTS: commitAttachments(); break; + case REQUEST_START_AUDIO_CALL: + triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VOICE_CALL); + break; + case REQUEST_START_VIDEO_CALL: + triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VIDEO_CALL); + break; case ATTACHMENT_CHOICE_CHOOSE_IMAGE: final List imageUris = Attachment.extractAttachments(getActivity(), data, Attachment.Type.IMAGE); mediaPreviewAdapter.addMediaPreviews(imageUris); @@ -870,7 +880,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (anyNeedsExternalStoragePermission(attachments) && !hasPermissions(REQUEST_COMMIT_ATTACHMENTS, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { return; } - if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(REQUEST_TRUST_KEYS_ATTACHMENTS)) { + if (trustKeysIfNeeded(conversation, REQUEST_TRUST_KEYS_ATTACHMENTS)) { return; } final PresenceSelector.OnPresenceSelected callback = () -> { @@ -1345,6 +1355,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return; } if (hasPermissions(REQUEST_START_AUDIO_CALL, Manifest.permission.RECORD_AUDIO)) { + if (Config.REQUIRE_RTP_VERIFICATION && trustKeysIfNeeded(conversation, REQUEST_START_AUDIO_CALL)) { + return; + } triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VOICE_CALL); } } @@ -1355,6 +1368,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return; } if (hasPermissions(REQUEST_START_VIDEO_CALL, Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)) { + if (Config.REQUIRE_RTP_VERIFICATION && trustKeysIfNeeded(conversation, REQUEST_START_VIDEO_CALL)) { + return; + } triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VIDEO_CALL); } } @@ -1365,7 +1381,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke Toast.makeText(getActivity(), R.string.only_one_call_at_a_time, Toast.LENGTH_LONG).show(); return; } - final Contact contact = conversation.getContact(); if (contact.getPresences().anySupport(Namespace.JINGLE_MESSAGE)) { triggerRtpSession(contact.getAccount(), contact.getJid().asBareJid(), action);