aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-12-16 21:53:58 +0100
committerChristian Schneppe <christian@pix-art.de>2017-12-16 21:53:58 +0100
commit55fe3495e6f12959a8a5273dd21cfadf093d4d03 (patch)
tree86c0fb953dbe7b57abf913ffac55d2b7e188aee4 /src
parent86bd13da678b8fa6e6b10cd43c18256cd2fdac19 (diff)
fixed workaround that allowed us to expire devices
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java15
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java2
2 files changed, 9 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
index a6f5d5b04..f81903a28 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -80,7 +80,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
private final SerialSingleThreadExecutor executor;
private int numPublishTriesOnEmptyPep = 0;
private boolean pepBroken = false;
- private AtomicBoolean ownPushPending = new AtomicBoolean(false);
+ private int lastDeviceListNotificationHash = 0;
private AtomicBoolean changeAccessMode = new AtomicBoolean(false);
@Override
@@ -348,7 +348,8 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
public void resetBrokenness() {
this.pepBroken = false;
- numPublishTriesOnEmptyPep = 0;
+ this.numPublishTriesOnEmptyPep = 0;
+ this.lastDeviceListNotificationHash = 0;
}
public void clearErrorsInFetchStatusMap(Jid jid) {
@@ -386,11 +387,13 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
}
public void registerDevices(final Jid jid, @NonNull final Set<Integer> deviceIds) {
- boolean me = jid.toBareJid().equals(account.getJid().toBareJid());
- if (me && ownPushPending.getAndSet(false)) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": ignoring own device update because of pending push");
+ final int hash = deviceIds.hashCode();
+ final boolean me = jid.toBareJid().equals(account.getJid().toBareJid());
+ if (me && hash == this.lastDeviceListNotificationHash) {
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": ignoring duplicate own device id list");
return;
}
+ this.lastDeviceListNotificationHash = hash;
boolean needsPublishing = me && !deviceIds.contains(getOwnDeviceId());
if (me) {
deviceIds.remove(getOwnDeviceId());
@@ -525,7 +528,6 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
private void publishDeviceIdsAndRefineAccessModel(final Set<Integer> ids, final boolean firstAttempt) {
final Bundle publishOptions = account.getXmppConnection().getFeatures().pepPublishOptions() ? PublishOptions.openAccess() : null;
IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(ids, publishOptions);
- ownPushPending.set(true);
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
@@ -549,7 +551,6 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
account.setOption(Account.OPTION_REQUIRES_ACCESS_MODE_CHANGE,false);
mXmppConnectionService.databaseBackend.updateAccount(account);
}
- ownPushPending.set(false);
if (packet.getType() == IqPacket.TYPE.ERROR) {
pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error"));
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index d1b69b0ea..f237ab106 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -294,7 +294,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} else if (AxolotlService.PEP_DEVICE_LIST.equals(node)) {
Element item = items.findChild("item");
Set<Integer> deviceIds = mXmppConnectionService.getIqParser().deviceIds(item);
- Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Received PEP device list (" + deviceIds + ") update from " + from + ", processing...");
+ Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Received PEP device list " + deviceIds + " update from " + from + ", processing... ");
AxolotlService axolotlService = account.getAxolotlService();
axolotlService.registerDevices(from, deviceIds);
mXmppConnectionService.updateAccountUi();