aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-05-25 11:15:14 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-05-25 11:15:14 +0200
commitf5796024567ff8cf605971ef93d23be792229af3 (patch)
tree3023e9a64794edf9b0dc3cf4a3096a95e5240dda
parent9d1a8c607fbd8b784f2cfdc6817938e03b3de093 (diff)
parent4cb49c4a9cf8c0bc3f38e6bac849b9dc0d55c63c (diff)
Merge branch 'master' into development
-rw-r--r--build.gradle2
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java15
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java2
3 files changed, 13 insertions, 6 deletions
diff --git a/build.gradle b/build.gradle
index 1515467a0..7580be361 100644
--- a/build.gradle
+++ b/build.gradle
@@ -45,7 +45,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
- versionCode 69
+ versionCode 70
versionName "1.5.0-alpha"
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index f682bccd3..0d48e1a5f 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -483,9 +483,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");
@@ -614,7 +621,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);
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);
}