create empty disco result on error to fire advance stream features event

This commit is contained in:
Daniel Gultsch 2019-08-13 21:18:32 +02:00
parent ad15fb1721
commit ed95dd64ad
2 changed files with 26 additions and 1 deletions

View file

@ -86,6 +86,18 @@ public class ServiceDiscoveryResult {
}
}
}
private ServiceDiscoveryResult() {
this.hash = "sha-1";
this.features = Collections.emptyList();
this.identities = Collections.emptyList();
this.ver = null;
this.forms = Collections.emptyList();
}
public static ServiceDiscoveryResult empty() {
return new ServiceDiscoveryResult();
}
public ServiceDiscoveryResult(Cursor cursor) throws JSONException {
this(

View file

@ -1205,8 +1205,21 @@ public class XmppConnection implements Runnable {
if (advancedStreamFeaturesLoaded && (jid.equals(Jid.of(account.getServer())) || jid.equals(account.getJid().asBareJid()))) {
enableAdvancedStreamFeatures();
}
} else {
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not query disco info for " + jid.toString());
final boolean serverOrAccount = jid.equals(Jid.of(account.getServer())) || jid.equals(account.getJid().asBareJid());
final boolean advancedStreamFeaturesLoaded;
if (serverOrAccount) {
synchronized (XmppConnection.this.disco) {
disco.put(jid, ServiceDiscoveryResult.empty());
advancedStreamFeaturesLoaded = disco.containsKey(Jid.of(account.getServer())) && disco.containsKey(account.getJid().asBareJid());
}
} else {
advancedStreamFeaturesLoaded = false;
}
if (advancedStreamFeaturesLoaded) {
enableAdvancedStreamFeatures();
}
}
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
if (mPendingServiceDiscoveries.decrementAndGet() == 0