aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/services
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-15 19:14:38 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-12-15 19:24:05 +0100
commit43dd681239ea5a287f5761597de5dcdc4daed3de (patch)
tree90ae48c08f096cebe8d222edbd1df850edee8ae3 /src/main/java/eu/siacs/conversations/services
parent85f36e9dbc416d0644bcc0e1f7d3790124786579 (diff)
timeout service discovery after 20s
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 0addbfd4..649ddacd 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -547,12 +547,18 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
} else if (account.getStatus() == Account.State.OFFLINE) {
reconnectAccount(account, true, interactive);
} else if (account.getStatus() == Account.State.CONNECTING) {
- long timeout = Config.CONNECT_TIMEOUT - ((SystemClock.elapsedRealtime() - account.getXmppConnection().getLastConnect()) / 1000);
+ long secondsSinceLastConnect = (SystemClock.elapsedRealtime() - account.getXmppConnection().getLastConnect()) / 1000;
+ long secondsSinceLastDisco = (SystemClock.elapsedRealtime() - account.getXmppConnection().getLastDiscoStarted()) / 1000;
+ long discoTimeout = Config.CONNECT_DISCO_TIMEOUT - secondsSinceLastDisco;
+ long timeout = Config.CONNECT_TIMEOUT - secondsSinceLastConnect;
if (timeout < 0) {
Log.d(Config.LOGTAG, account.getJid() + ": time out during connect reconnecting");
reconnectAccount(account, true, interactive);
+ } else if (discoTimeout < 0) {
+ account.getXmppConnection().sendDiscoTimeout();
+ scheduleWakeUpCall((int) Math.min(timeout,discoTimeout), account.getUuid().hashCode());
} else {
- scheduleWakeUpCall((int) timeout, account.getUuid().hashCode());
+ scheduleWakeUpCall((int) Math.min(timeout,discoTimeout), account.getUuid().hashCode());
}
} else {
if (account.getXmppConnection().getTimeToNextAttempt() <= 0) {
@@ -748,7 +754,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
stopSelf();
}
- protected void scheduleWakeUpCall(int seconds, int requestCode) {
+ public void scheduleWakeUpCall(int seconds, int requestCode) {
final long timeToWake = SystemClock.elapsedRealtime() + (seconds < 0 ? 1 : seconds + 1) * 1000;
Context context = getApplicationContext();