use omemo verification only if omemo is enabled in conversation

This commit is contained in:
Daniel Gultsch 2021-03-03 12:55:27 +01:00
parent e81fb1b24e
commit d52c46d582
1 changed files with 22 additions and 6 deletions

View File

@ -669,7 +669,15 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
this.message.setServerMsgId(serverMsgId);
}
this.message.setTime(timestamp);
this.omemoVerification.setDeviceId(proceed.getDeviceId());
final Integer remoteDeviceId = proceed.getDeviceId();
if (isOmemoEnabled()) {
this.omemoVerification.setDeviceId(remoteDeviceId);
} else {
if (remoteDeviceId != null) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid()+": remote party signaled support for OMEMO verification but we have OMEMO disabled");
}
this.omemoVerification.setDeviceId(null);
}
this.sendSessionInitiate(media, State.SESSION_INITIALIZED_PRE_APPROVED);
} else {
Log.d(Config.LOGTAG, String.format("%s: ignoring proceed because already in %s", id.account.getJid().asBareJid(), this.state));
@ -1126,16 +1134,24 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
final Element intent = messagePacket.addChild(action, Namespace.JINGLE_MESSAGE).setAttribute("id", id.sessionId);
if ("proceed".equals(action)) {
messagePacket.setId(JINGLE_MESSAGE_PROCEED_ID_PREFIX + id.sessionId);
//TODO only do this if OMEMO is enable so we have an easy way to opt out
if (isOmemoEnabled()) {
final int deviceId = id.account.getAxolotlService().getOwnDeviceId();
final Element device = intent.addChild("device", Namespace.OMEMO_DTLS_SRTP_VERIFICATION);
device.setAttribute("id", deviceId);
}
}
messagePacket.addChild("store", "urn:xmpp:hints");
xmppConnectionService.sendMessagePacket(id.account, messagePacket);
}
private boolean isOmemoEnabled() {
final Conversational conversational = message.getConversation();
if (conversational instanceof Conversation) {
return ((Conversation) conversational).getNextEncryption() == Message.ENCRYPTION_AXOLOTL;
}
return false;
}
private void acceptCallFromSessionInitialized() {
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
sendSessionAccept();