From a535d45ec3cbb2f3f50882775692b98957e4ea26 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 25 May 2015 04:49:36 +0200 Subject: [PATCH 1/3] log connection age and reshedule ping check --- .../services/XmppConnectionService.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 63d9ba7a8..97c52156c 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -482,9 +482,16 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa long lastSent = account.getXmppConnection().getLastPingSent(); long pingInterval = "ui".equals(action) ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000; long msToNextPing = (Math.max(lastReceived,lastSent) + pingInterval) - SystemClock.elapsedRealtime(); - if (lastSent > lastReceived && (lastSent + Config.PING_TIMEOUT * 1000) < SystemClock.elapsedRealtime()) { - Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": ping timeout"); - this.reconnectAccount(account, true); + long pingTimeoutIn = (lastSent + Config.PING_TIMEOUT * 1000) - SystemClock.elapsedRealtime(); + if (lastSent > lastReceived) { + if (pingTimeoutIn < 0) { + long age = (SystemClock.elapsedRealtime() - account.getXmppConnection().getLastConnect()) / 1000; + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": ping timeout. connection age was: "+age+"s"); + this.reconnectAccount(account, true); + } else { + int secs = (int) (pingTimeoutIn / 1000); + this.scheduleWakeUpCall(secs,account.getUuid().hashCode()); + } } else if (msToNextPing <= 0) { account.getXmppConnection().sendPing(); Log.d(Config.LOGTAG, account.getJid().toBareJid()+" send ping"); @@ -613,7 +620,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } protected void scheduleWakeUpCall(int seconds, int requestCode) { - final long timeToWake = SystemClock.elapsedRealtime() + (seconds + 1) * 1000; + final long timeToWake = SystemClock.elapsedRealtime() + (seconds < 0 ? 1 : seconds + 1) * 1000; Context context = getApplicationContext(); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); From 36034815ee34c9a48c5236329914439bd5885179 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 25 May 2015 04:54:11 +0200 Subject: [PATCH 2/3] use same sm check inside xmppconnection and out --- src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 9bda3c096..d52ebee59 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -921,7 +921,7 @@ public class XmppConnection implements Runnable { ++stanzasSent; } tagWriter.writeStanzaAsync(packet); - if (packet instanceof MessagePacket && packet.getId() != null && this.streamId != null) { + if (packet instanceof MessagePacket && packet.getId() != null && getFeatures().sm()) { if (Config.EXTENDED_SM_LOGGING) { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": requesting ack for message stanza #" + stanzasSent); } From 4cb49c4a9cf8c0bc3f38e6bac849b9dc0d55c63c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 25 May 2015 05:00:33 +0200 Subject: [PATCH 3/3] version bump to 1.4.3 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index ef3b50eaa..6d12080f0 100644 --- a/build.gradle +++ b/build.gradle @@ -44,8 +44,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 21 - versionCode 68 - versionName "1.4.2" + versionCode 69 + versionName "1.4.3" } compileOptions {