Skip to content

Commit

Permalink
Merge tag '2.14.1' into ninja-main
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
  • Loading branch information
christianrowlands committed Apr 3, 2024
2 parents 4fb3353 + 429b190 commit 1bb1f90
Show file tree
Hide file tree
Showing 24 changed files with 655 additions and 206 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### Version 2.14.1

* Fix A/V calls on Android 8
* Fix race conditions in new call integration
* Fix video compression sticking around

### Version 2.14.0

* Improve integration of A/V calls into the operating system
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.2'
classpath 'com.android.tools.build:gradle:8.3.1'
classpath 'com.google.gms:google-services:4.4.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
}
Expand Down
13 changes: 10 additions & 3 deletions conversations.doap
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,19 @@
<xmpp:version>0.1.0</xmpp:version>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0490.html"/>
<xmpp:status>complete</xmpp:status>
<xmpp:version>0.1.0</xmpp:version>
</xmpp:SupportedXep>
</implements>

<release>
<Version>
<revision>2.13.4</revision>
<created>2024-02-20</created>
<file-release rdf:resource="https://codeberg.org/iNPUTmice/Conversations/archive/2.13.4.tar.gz"/>
<revision>2.14.0</revision>
<created>2024-03-22</created>
<file-release rdf:resource="https://codeberg.org/iNPUTmice/Conversations/archive/2.14.0.tar.gz"/>
</Version>
</release>
</Project>
Expand Down
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/4210404.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Fix A/V calls on Android 8
* Fix race conditions in new call integration
* Fix video compression sticking around
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
2 changes: 2 additions & 0 deletions src/main/java/eu/siacs/conversations/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public static boolean multipleEncryptionChoices() {

public static final boolean USE_RANDOM_RESOURCE_ON_EVERY_BIND = false;

public static final boolean MESSAGE_DISPLAYED_SYNCHRONIZATION = false;

public static final boolean ALLOW_NON_TLS_CONNECTIONS =
false; // very dangerous. you should have a good reason to set this to true

Expand Down
31 changes: 26 additions & 5 deletions src/main/java/eu/siacs/conversations/entities/Conversation.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import androidx.annotation.Nullable;

import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

import org.json.JSONArray;
Expand Down Expand Up @@ -84,6 +85,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
private ChatState mOutgoingChatState = Config.DEFAULT_CHAT_STATE;
private ChatState mIncomingChatState = Config.DEFAULT_CHAT_STATE;
private String mFirstMamReference = null;
private String displayState = null;

public Conversation(final String name, final Account account, final Jid contactJid,
final int mode) {
Expand Down Expand Up @@ -437,6 +439,17 @@ public Message findMessageWithRemoteId(String id, Jid counterpart) {
return null;
}

public Message findReceivedWithRemoteId(final String id) {
synchronized (this.messages) {
for (final Message message : this.messages) {
if (message.getStatus() == Message.STATUS_RECEIVED && id.equals(message.getRemoteMsgId())) {
return message;
}
}
}
return null;
}

public Message findMessageWithServerMsgId(String id) {
synchronized (this.messages) {
for (Message message : this.messages) {
Expand Down Expand Up @@ -576,20 +589,20 @@ public boolean isRead() {
}
}

public List<Message> markRead(String upToUuid) {
final List<Message> unread = new ArrayList<>();
public List<Message> markRead(final String upToUuid) {
final ImmutableList.Builder<Message> unread = new ImmutableList.Builder<>();
synchronized (this.messages) {
for (Message message : this.messages) {
for (final Message message : this.messages) {
if (!message.isRead()) {
message.markRead();
unread.add(message);
}
if (message.getUuid().equals(upToUuid)) {
return unread;
return unread.build();
}
}
}
return unread;
return unread.build();
}

public Message getLatestMessage() {
Expand Down Expand Up @@ -1109,6 +1122,14 @@ public String getAvatarName() {
return getName().toString();
}

public void setDisplayState(final String stanzaId) {
this.displayState = stanzaId;
}

public String getDisplayState() {
return this.displayState;
}

public interface OnMessageFound {
void onMessageFound(final Message message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

import android.util.Base64;

import eu.siacs.conversations.BuildConfig;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.XmppConnection;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
Expand All @@ -12,54 +21,41 @@
import java.util.Locale;
import java.util.TimeZone;

import eu.siacs.conversations.BuildConfig;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.jingle.stanzas.FileTransferDescription;

public abstract class AbstractGenerator {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
private final String[] FEATURES = {
Namespace.JINGLE,
Namespace.JINGLE_APPS_FILE_TRANSFER,
Namespace.JINGLE_TRANSPORTS_S5B,
Namespace.JINGLE_TRANSPORTS_IBB,
Namespace.JINGLE_ENCRYPTED_TRANSPORT,
Namespace.JINGLE_ENCRYPTED_TRANSPORT_OMEMO,
"http://jabber.org/protocol/muc",
"jabber:x:conference",
Namespace.OOB,
"http://jabber.org/protocol/caps",
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",
Namespace.NICK + "+notify",
"urn:xmpp:ping",
"jabber:iq:version",
"http://jabber.org/protocol/chatstates"
private static final SimpleDateFormat DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
private final String[] STATIC_FEATURES = {
Namespace.JINGLE,
Namespace.JINGLE_APPS_FILE_TRANSFER,
Namespace.JINGLE_TRANSPORTS_S5B,
Namespace.JINGLE_TRANSPORTS_IBB,
Namespace.JINGLE_ENCRYPTED_TRANSPORT,
Namespace.JINGLE_ENCRYPTED_TRANSPORT_OMEMO,
"http://jabber.org/protocol/muc",
"jabber:x:conference",
Namespace.OOB,
"http://jabber.org/protocol/caps",
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",
Namespace.NICK + "+notify",
"urn:xmpp:ping",
"jabber:iq:version",
"http://jabber.org/protocol/chatstates"
};
private final String[] MESSAGE_CONFIRMATION_FEATURES = {
"urn:xmpp:chat-markers:0",
"urn:xmpp:receipts"
};
private final String[] MESSAGE_CORRECTION_FEATURES = {
"urn:xmpp:message-correct:0"
"urn:xmpp:chat-markers:0", "urn:xmpp:receipts"
};
private final String[] MESSAGE_CORRECTION_FEATURES = {"urn:xmpp:message-correct:0"};
private final String[] PRIVACY_SENSITIVE = {
"urn:xmpp:time" //XEP-0202: Entity Time leaks time zone
"urn:xmpp:time" // XEP-0202: Entity Time leaks time zone
};
private final String[] VOIP_NAMESPACES = {
Namespace.JINGLE_TRANSPORT_ICE_UDP,
Namespace.JINGLE_FEATURE_AUDIO,
Namespace.JINGLE_FEATURE_VIDEO,
Namespace.JINGLE_APPS_RTP,
Namespace.JINGLE_APPS_DTLS,
Namespace.JINGLE_MESSAGE
Namespace.JINGLE_TRANSPORT_ICE_UDP,
Namespace.JINGLE_FEATURE_AUDIO,
Namespace.JINGLE_FEATURE_VIDEO,
Namespace.JINGLE_APPS_RTP,
Namespace.JINGLE_APPS_DTLS,
Namespace.JINGLE_MESSAGE
};
protected XmppConnectionService mXmppConnectionService;

Expand Down Expand Up @@ -90,7 +86,11 @@ String getIdentityType() {

String getCapHash(final Account account) {
StringBuilder s = new StringBuilder();
s.append("client/").append(getIdentityType()).append("//").append(getIdentityName()).append('<');
s.append("client/")
.append(getIdentityType())
.append("//")
.append(getIdentityName())
.append('<');
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");
Expand All @@ -107,7 +107,10 @@ String getCapHash(final Account account) {

public List<String> getFeatures(Account account) {
final XmppConnection connection = account.getXmppConnection();
final ArrayList<String> features = new ArrayList<>(Arrays.asList(FEATURES));
final ArrayList<String> features = new ArrayList<>(Arrays.asList(STATIC_FEATURES));
if (Config.MESSAGE_DISPLAYED_SYNCHRONIZATION) {
features.add(Namespace.MDS_DISPLAYED + "+notify");
}
if (mXmppConnectionService.confirmMessages()) {
features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES));
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/eu/siacs/conversations/generator/IqGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public IqPacket retrieveBookmarks() {
return retrieve(Namespace.BOOKMARKS2, null);
}

public IqPacket retrieveMds() {
return retrieve(Namespace.MDS_DISPLAYED, null);
}

public IqPacket publishNick(String nick) {
final Element item = new Element("item");
item.setAttribute("id", "current");
Expand Down Expand Up @@ -264,6 +268,24 @@ public Element publishBookmarkItem(final Bookmark bookmark) {
return conference;
}

public Element mdsDisplayed(final String stanzaId, final Conversation conversation) {
final Jid by;
if (conversation.getMode() == Conversation.MODE_MULTI) {
by = conversation.getJid().asBareJid();
} else {
by = conversation.getAccount().getJid().asBareJid();
}
return mdsDisplayed(stanzaId, by);
}

private Element mdsDisplayed(final String stanzaId, final Jid by) {
final Element displayed = new Element("displayed", Namespace.MDS_DISPLAYED);
final Element stanzaIdElement = displayed.addChild("stanza-id", Namespace.STANZA_IDS);
stanzaIdElement.setAttribute("id", stanzaId);
stanzaIdElement.setAttribute("by", by);
return displayed;
}

public IqPacket publishBundles(final SignedPreKeyRecord signedPreKeyRecord, final IdentityKey identityKey,
final Set<PreKeyRecord> preKeyRecords, final int deviceId, Bundle publishOptions) {
final Element item = new Element("item");
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/eu/siacs/conversations/parser/MessageParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,17 @@ private void parseEvent(final Element event, final Jid from, final Account accou
mXmppConnectionService.updateConversationUi();
}
}
} else if (Config.MESSAGE_DISPLAYED_SYNCHRONIZATION
&& Namespace.MDS_DISPLAYED.equals(node)
&& account.getJid().asBareJid().equals(from)) {
final Element item = items.findChild("item");
mXmppConnectionService.processMdsItem(account, item);
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + " received pubsub notification for node=" + node);
Log.d(
Config.LOGTAG,
account.getJid().asBareJid()
+ " received pubsub notification for node="
+ node);
}
}

Expand Down Expand Up @@ -985,12 +994,18 @@ public void onMessagePacketReceived(Account account, MessagePacket original) {
}
}
}
Element displayed = packet.findChild("displayed", "urn:xmpp:chat-markers:0");
final Element displayed = packet.findChild("displayed", "urn:xmpp:chat-markers:0");
if (displayed != null) {
final String id = displayed.getAttribute("id");
final Jid sender = InvalidJid.getNullForInvalid(displayed.getAttributeAsJid("sender"));
if (packet.fromAccount(account) && !selfAddressed) {
dismissNotification(account, counterpart, query, id);
final Conversation c =
mXmppConnectionService.find(account, counterpart.asBareJid());
final Message message =
(c == null || id == null) ? null : c.findReceivedWithRemoteId(id);
if (message != null && (query == null || query.isCatchup())) {
mXmppConnectionService.markReadUpTo(c, message);
}
if (query == null) {
activateGracePeriod(account);
}
Expand All @@ -1012,7 +1027,7 @@ public void onMessagePacketReceived(Account account, MessagePacket original) {
final boolean trueJidMatchesAccount = account.getJid().asBareJid().equals(trueJid == null ? null : trueJid.asBareJid());
if (trueJidMatchesAccount || conversation.getMucOptions().isSelf(counterpart)) {
if (!message.isRead() && (query == null || query.isCatchup())) { //checking if message is unread fixes race conditions with reflections
mXmppConnectionService.markRead(conversation);
mXmppConnectionService.markReadUpTo(conversation, message);
}
} else if (!counterpart.isBareJid() && trueJid != null) {
final ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public void startRingBack() {
final var toneGenerator =
new ToneGenerator(
AudioManager.STREAM_MUSIC,
CallIntegration.DEFAULT_VOLUME);
CallIntegration.DEFAULT_TONE_VOLUME);
toneGenerator.startTone(ToneGenerator.TONE_CDMA_DIAL_TONE_LITE, 750);
},
0,
Expand Down
Loading

0 comments on commit 1bb1f90

Please sign in to comment.