better detect broken pep

mark pep as broken when publishing bundle or device list failed
reset 'brokenness' when account is getting disabled
This commit is contained in:
Daniel Gultsch 2016-04-05 13:31:03 +02:00
parent a968260b18
commit ecaf75e5ec
2 changed files with 10 additions and 2 deletions

View file

@ -314,6 +314,11 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
return this.pepBroken; return this.pepBroken;
} }
public void resetBrokenness() {
this.pepBroken = false;
numPublishTriesOnEmptyPep = 0;
}
public void regenerateKeys(boolean wipeOther) { public void regenerateKeys(boolean wipeOther) {
axolotlStore.regenerate(); axolotlStore.regenerate();
sessions.clear(); sessions.clear();
@ -448,7 +453,8 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
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) {
if (packet.getType() != IqPacket.TYPE.RESULT) { if (packet.getType() == IqPacket.TYPE.ERROR) {
pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error")); Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error"));
} }
} }
@ -612,7 +618,8 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
Log.d(Config.LOGTAG, getLogprefix(account) + "Announcing device " + getOwnDeviceId()); Log.d(Config.LOGTAG, getLogprefix(account) + "Announcing device " + getOwnDeviceId());
publishOwnDeviceIdIfNeeded(); publishOwnDeviceIdIfNeeded();
} }
} else { } else if (packet.getType() == IqPacket.TYPE.ERROR) {
pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing bundle: " + packet.findChild("error")); Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing bundle: " + packet.findChild("error"));
} }
} }

View file

@ -2581,6 +2581,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
disconnect(account, force); disconnect(account, force);
account.getRoster().clearPresences(); account.getRoster().clearPresences();
connection.resetEverything(); connection.resetEverything();
account.getAxolotlService().resetBrokenness();
} }
} }
} }