leaving low ping timeout mode after coming online
This commit is contained in:
parent
e538272417
commit
e582b9fc10
|
@ -295,6 +295,11 @@ public class XmppConnectionService extends Service {
|
|||
mOnAccountUpdate.onAccountUpdate();
|
||||
}
|
||||
if (account.getStatus() == Account.State.ONLINE) {
|
||||
synchronized (mLowPingTimeoutMode) {
|
||||
if (mLowPingTimeoutMode.remove(account.getJid().toBareJid())) {
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": leaving low ping timeout mode");
|
||||
}
|
||||
}
|
||||
if (account.setShowErrorNotification(true)) {
|
||||
databaseBackend.updateAccount(account);
|
||||
}
|
||||
|
@ -336,14 +341,16 @@ public class XmppConnectionService extends Service {
|
|||
&& listeners;
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": push mode="+Boolean.toString(pushMode)+" listeners="+Boolean.toString(listeners));
|
||||
if (!disabled && !pushMode) {
|
||||
synchronized (mLowPingTimeoutMode) {
|
||||
if (mLowPingTimeoutMode.contains(account.getJid().toBareJid())) {
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": went into offline state during low ping mode. reconnecting now");
|
||||
reconnectAccount(account,true,false);
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": went into offline state during low ping mode. reconnecting now");
|
||||
reconnectAccount(account, true, false);
|
||||
} else {
|
||||
int timeToReconnect = mRandom.nextInt(20) + 10;
|
||||
scheduleWakeUpCall(timeToReconnect, account.getUuid().hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (account.getStatus() == Account.State.REGISTRATION_SUCCESSFUL) {
|
||||
databaseBackend.updateAccount(account);
|
||||
reconnectAccount(account, true, false);
|
||||
|
@ -628,6 +635,7 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
}
|
||||
if (account.getStatus() == Account.State.ONLINE) {
|
||||
synchronized (mLowPingTimeoutMode) {
|
||||
long lastReceived = account.getXmppConnection().getLastPacketReceived();
|
||||
long lastSent = account.getXmppConnection().getLastPingSent();
|
||||
long pingInterval = (Config.PUSH_MODE || "ui".equals(action)) ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000;
|
||||
|
@ -654,7 +662,8 @@ public class XmppConnectionService extends Service {
|
|||
} else {
|
||||
this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode());
|
||||
if (mLowPingTimeoutMode.remove(account.getJid().toBareJid())) {
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": leaving low ping timeout mode");
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": leaving low ping timeout mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -695,10 +704,12 @@ public class XmppConnectionService extends Service {
|
|||
account.getXmppConnection().waitForPush();
|
||||
cancelWakeUpCall(account.getUuid().hashCode());
|
||||
} else {
|
||||
synchronized (mLowPingTimeoutMode) {
|
||||
final boolean lowTimeout = mLowPingTimeoutMode.contains(account.getJid().toBareJid());
|
||||
account.getXmppConnection().sendPing();
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + " send ping (action=" + action + ",listeners="+Boolean.toString(listeners)+",lowTimeout="+Boolean.toString(lowTimeout)+")");
|
||||
scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT: Config.PING_TIMEOUT, account.getUuid().hashCode());
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + " send ping (action=" + action + ",listeners=" + Boolean.toString(listeners) + ",lowTimeout=" + Boolean.toString(lowTimeout) + ")");
|
||||
scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT, account.getUuid().hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue