fixed session time

This commit is contained in:
Daniel Gultsch 2015-08-25 11:11:32 +02:00
parent dd20f41f1b
commit 476db24c10
1 changed files with 2 additions and 7 deletions

View File

@ -318,7 +318,6 @@ public class XmppConnection implements Runnable {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": stream management(" + smVersion + ") enabled"); + ": stream management(" + smVersion + ") enabled");
} }
this.lastSessionStarted = SystemClock.elapsedRealtime();
this.stanzasReceived = 0; this.stanzasReceived = 0;
final RequestPacket r = new RequestPacket(smVersion); final RequestPacket r = new RequestPacket(smVersion);
tagWriter.writeStanzaAsync(r); tagWriter.writeStanzaAsync(r);
@ -784,6 +783,7 @@ public class XmppConnection implements Runnable {
sendServiceDiscoveryInfo(account.getJid().toBareJid()); sendServiceDiscoveryInfo(account.getJid().toBareJid());
sendServiceDiscoveryItems(account.getServer()); sendServiceDiscoveryItems(account.getServer());
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource()); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource());
this.lastSessionStarted = SystemClock.elapsedRealtime();
changeStatus(Account.State.ONLINE); changeStatus(Account.State.ONLINE);
if (bindListener != null) { if (bindListener != null) {
bindListener.onBind(account); bindListener.onBind(account);
@ -1100,12 +1100,7 @@ public class XmppConnection implements Runnable {
} }
public long getLastSessionEstablished() { public long getLastSessionEstablished() {
final long diff; final long diff = SystemClock.elapsedRealtime() - this.lastSessionStarted;
if (this.lastSessionStarted == 0) {
diff = SystemClock.elapsedRealtime() - this.lastConnect;
} else {
diff = SystemClock.elapsedRealtime() - this.lastSessionStarted;
}
return System.currentTimeMillis() - diff; return System.currentTimeMillis() - diff;
} }