Only announce device after publishing bundle
This commit is contained in:
parent
f6b7a25e29
commit
c4a548ada0
|
@ -231,8 +231,7 @@ public class AxolotlService {
|
||||||
axolotlStore.regenerate();
|
axolotlStore.regenerate();
|
||||||
sessions.clear();
|
sessions.clear();
|
||||||
fetchStatusMap.clear();
|
fetchStatusMap.clear();
|
||||||
publishBundlesIfNeeded();
|
publishBundlesIfNeeded(true);
|
||||||
publishOwnDeviceIdIfNeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOwnDeviceId() {
|
public int getOwnDeviceId() {
|
||||||
|
@ -365,7 +364,7 @@ public class AxolotlService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void publishBundlesIfNeeded() {
|
public void publishBundlesIfNeeded(final boolean announceAfter) {
|
||||||
if (pepBroken) {
|
if (pepBroken) {
|
||||||
Log.d(Config.LOGTAG, getLogprefix(account) + "publishBundlesIfNeeded called, but PEP is broken. Ignoring... ");
|
Log.d(Config.LOGTAG, getLogprefix(account) + "publishBundlesIfNeeded called, but PEP is broken. Ignoring... ");
|
||||||
return;
|
return;
|
||||||
|
@ -448,10 +447,23 @@ public class AxolotlService {
|
||||||
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
// TODO: implement this!
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Published bundle, got: " + packet);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Successfully published bundle. ");
|
||||||
|
if (announceAfter) {
|
||||||
|
Log.d(Config.LOGTAG, getLogprefix(account) + "Announcing device " + getOwnDeviceId());
|
||||||
|
publishOwnDeviceIdIfNeeded();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing bundle: " + packet.findChild("error"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG, getLogprefix(account) + "Bundle " + getOwnDeviceId() + " in PEP was current");
|
||||||
|
if (announceAfter) {
|
||||||
|
Log.d(Config.LOGTAG, getLogprefix(account) + "Announcing device " + getOwnDeviceId());
|
||||||
|
publishOwnDeviceIdIfNeeded();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Failed to publish bundle " + getOwnDeviceId() + ", reason: " + e.getMessage());
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Failed to publish bundle " + getOwnDeviceId() + ", reason: " + e.getMessage());
|
||||||
|
@ -733,7 +745,7 @@ public class AxolotlService {
|
||||||
plaintextMessage = message.decrypt(session, getOwnDeviceId());
|
plaintextMessage = message.decrypt(session, getOwnDeviceId());
|
||||||
Integer preKeyId = session.getPreKeyId();
|
Integer preKeyId = session.getPreKeyId();
|
||||||
if (preKeyId != null) {
|
if (preKeyId != null) {
|
||||||
publishBundlesIfNeeded();
|
publishBundlesIfNeeded(false);
|
||||||
session.resetPreKeyId();
|
session.resetPreKeyId();
|
||||||
}
|
}
|
||||||
} catch (CryptoFailedException e) {
|
} catch (CryptoFailedException e) {
|
||||||
|
|
|
@ -165,8 +165,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
mMessageArchiveService.executePendingQueries(account);
|
mMessageArchiveService.executePendingQueries(account);
|
||||||
mJingleConnectionManager.cancelInTransmission();
|
mJingleConnectionManager.cancelInTransmission();
|
||||||
syncDirtyContacts(account);
|
syncDirtyContacts(account);
|
||||||
account.getAxolotlService().publishOwnDeviceIdIfNeeded();
|
account.getAxolotlService().publishBundlesIfNeeded(true);
|
||||||
account.getAxolotlService().publishBundlesIfNeeded();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final OnMessageAcknowledged mOnMessageAcknowledgedListener = new OnMessageAcknowledged() {
|
private final OnMessageAcknowledged mOnMessageAcknowledgedListener = new OnMessageAcknowledged() {
|
||||||
|
|
Loading…
Reference in New Issue