made connect time out more failsave

This commit is contained in:
iNPUTmice 2015-01-25 20:52:53 +01:00
parent 4afdd6480a
commit f0d428a56d
1 changed files with 8 additions and 5 deletions

View File

@ -436,11 +436,14 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
account.setXmppConnection(this.createConnection(account)); account.setXmppConnection(this.createConnection(account));
} }
new Thread(account.getXmppConnection()).start(); new Thread(account.getXmppConnection()).start();
} else if ((account.getStatus() == Account.State.CONNECTING) } else if (account.getStatus() == Account.State.CONNECTING) {
&& ((SystemClock.elapsedRealtime() - account long timeout = Config.CONNECT_TIMEOUT - ((SystemClock.elapsedRealtime() - account.getXmppConnection().getLastConnect()) / 1000);
.getXmppConnection().getLastConnect()) / 1000 >= Config.CONNECT_TIMEOUT)) { if (timeout < 0) {
Log.d(Config.LOGTAG, account.getJid()+ ": time out during connect reconnecting"); Log.d(Config.LOGTAG, account.getJid() + ": time out during connect reconnecting");
reconnectAccount(account, true); reconnectAccount(account, true);
} else {
scheduleWakeUpCall((int) timeout,account.getUuid().hashCode());
}
} else { } else {
if (account.getXmppConnection().getTimeToNextAttempt() <= 0) { if (account.getXmppConnection().getTimeToNextAttempt() <= 0) {
reconnectAccount(account, true); reconnectAccount(account, true);