Merge branch 'master' into development

This commit is contained in:
Daniel Gultsch 2015-05-25 11:15:14 +02:00
commit f579602456
3 changed files with 13 additions and 6 deletions

View File

@ -45,7 +45,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 21 targetSdkVersion 21
versionCode 69 versionCode 70
versionName "1.5.0-alpha" versionName "1.5.0-alpha"
} }

View File

@ -483,9 +483,16 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
long lastSent = account.getXmppConnection().getLastPingSent(); long lastSent = account.getXmppConnection().getLastPingSent();
long pingInterval = "ui".equals(action) ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000; long pingInterval = "ui".equals(action) ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000;
long msToNextPing = (Math.max(lastReceived,lastSent) + pingInterval) - SystemClock.elapsedRealtime(); long msToNextPing = (Math.max(lastReceived,lastSent) + pingInterval) - SystemClock.elapsedRealtime();
if (lastSent > lastReceived && (lastSent + Config.PING_TIMEOUT * 1000) < SystemClock.elapsedRealtime()) { long pingTimeoutIn = (lastSent + Config.PING_TIMEOUT * 1000) - SystemClock.elapsedRealtime();
Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": ping timeout"); 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); this.reconnectAccount(account, true);
} else {
int secs = (int) (pingTimeoutIn / 1000);
this.scheduleWakeUpCall(secs,account.getUuid().hashCode());
}
} else if (msToNextPing <= 0) { } else if (msToNextPing <= 0) {
account.getXmppConnection().sendPing(); account.getXmppConnection().sendPing();
Log.d(Config.LOGTAG, account.getJid().toBareJid()+" send ping"); 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) { 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(); Context context = getApplicationContext();
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

View File

@ -921,7 +921,7 @@ public class XmppConnection implements Runnable {
++stanzasSent; ++stanzasSent;
} }
tagWriter.writeStanzaAsync(packet); 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) { if (Config.EXTENDED_SM_LOGGING) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": requesting ack for message stanza #" + stanzasSent); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": requesting ack for message stanza #" + stanzasSent);
} }