invoke omemo trust/fetch activity when triggering phone call in require_verification mode

This commit is contained in:
Daniel Gultsch 2021-05-04 17:52:17 +02:00
parent 3b25fb9038
commit 9544b994dc
2 changed files with 19 additions and 3 deletions

View File

@ -119,6 +119,7 @@ public final class Config {
public static final boolean ENCRYPT_ON_HTTP_UPLOADED = false; 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 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 public static final boolean ONLY_INTERNAL_STORAGE = false; //use internal storage instead of sdcard to save attachments

View File

@ -734,7 +734,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (body.length() == 0 || conversation == null) { if (body.length() == 0 || conversation == null) {
return; return;
} }
if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(REQUEST_TRUST_KEYS_TEXT)) { if (trustKeysIfNeeded(conversation, REQUEST_TRUST_KEYS_TEXT)) {
return; return;
} }
final Message message; 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) { protected boolean trustKeysIfNeeded(int requestCode) {
AxolotlService axolotlService = conversation.getAccount().getAxolotlService(); AxolotlService axolotlService = conversation.getAccount().getAxolotlService();
final List<Jid> targets = axolotlService.getCryptoTargets(conversation); final List<Jid> targets = axolotlService.getCryptoTargets(conversation);
@ -824,6 +828,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
case REQUEST_TRUST_KEYS_ATTACHMENTS: case REQUEST_TRUST_KEYS_ATTACHMENTS:
commitAttachments(); commitAttachments();
break; 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: case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
final List<Attachment> imageUris = Attachment.extractAttachments(getActivity(), data, Attachment.Type.IMAGE); final List<Attachment> imageUris = Attachment.extractAttachments(getActivity(), data, Attachment.Type.IMAGE);
mediaPreviewAdapter.addMediaPreviews(imageUris); 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)) { if (anyNeedsExternalStoragePermission(attachments) && !hasPermissions(REQUEST_COMMIT_ATTACHMENTS, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
return; return;
} }
if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(REQUEST_TRUST_KEYS_ATTACHMENTS)) { if (trustKeysIfNeeded(conversation, REQUEST_TRUST_KEYS_ATTACHMENTS)) {
return; return;
} }
final PresenceSelector.OnPresenceSelected callback = () -> { final PresenceSelector.OnPresenceSelected callback = () -> {
@ -1345,6 +1355,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return; return;
} }
if (hasPermissions(REQUEST_START_AUDIO_CALL, Manifest.permission.RECORD_AUDIO)) { 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); triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VOICE_CALL);
} }
} }
@ -1355,6 +1368,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return; return;
} }
if (hasPermissions(REQUEST_START_VIDEO_CALL, Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)) { 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); 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(); Toast.makeText(getActivity(), R.string.only_one_call_at_a_time, Toast.LENGTH_LONG).show();
return; return;
} }
final Contact contact = conversation.getContact(); final Contact contact = conversation.getContact();
if (contact.getPresences().anySupport(Namespace.JINGLE_MESSAGE)) { if (contact.getPresences().anySupport(Namespace.JINGLE_MESSAGE)) {
triggerRtpSession(contact.getAccount(), contact.getJid().asBareJid(), action); triggerRtpSession(contact.getAccount(), contact.getJid().asBareJid(), action);