don't throw assertion error when building session with same device id from other contact

This commit is contained in:
Daniel Gultsch 2016-12-28 22:15:24 +01:00
parent b8f67bfaa3
commit fcd9ab17fe

View file

@ -364,6 +364,10 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
return axolotlStore.getLocalRegistrationId(); return axolotlStore.getLocalRegistrationId();
} }
public AxolotlAddress getOwnAxolotlAddress() {
return new AxolotlAddress(account.getJid().toBareJid().toPreppedString(),getOwnDeviceId());
}
public Set<Integer> getOwnDeviceIds() { public Set<Integer> getOwnDeviceIds() {
return this.deviceIds.get(account.getJid().toBareJid()); return this.deviceIds.get(account.getJid().toBareJid());
} }
@ -453,6 +457,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
} else { } else {
Element item = mXmppConnectionService.getIqParser().getItem(packet); Element item = mXmppConnectionService.getIqParser().getItem(packet);
Set<Integer> deviceIds = mXmppConnectionService.getIqParser().deviceIds(item); Set<Integer> deviceIds = mXmppConnectionService.getIqParser().deviceIds(item);
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": retrieved own device list: "+deviceIds);
registerDevices(account.getJid().toBareJid(),deviceIds); registerDevices(account.getJid().toBareJid(),deviceIds);
} }
} }
@ -822,7 +827,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
private void buildSessionFromPEP(final AxolotlAddress address) { private void buildSessionFromPEP(final AxolotlAddress address) {
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Building new session for " + address.toString()); Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Building new session for " + address.toString());
if (address.getDeviceId() == getOwnDeviceId()) { if (address.equals(getOwnAxolotlAddress())) {
throw new AssertionError("We should NEVER build a session with ourselves. What happened here?!"); throw new AssertionError("We should NEVER build a session with ourselves. What happened here?!");
} }