code clean up in processAccountState()
This commit is contained in:
parent
928db01ae8
commit
a162d72c2a
|
@ -906,20 +906,17 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processAccountState(Account account, boolean interactive, boolean isUiAction, boolean isAccountPushed, HashSet<Account> pingCandidates) {
|
private boolean processAccountState(Account account, boolean interactive, boolean isUiAction, boolean isAccountPushed, HashSet<Account> pingCandidates) {
|
||||||
boolean pingNow = false;
|
if (!account.getStatus().isAttemptReconnect()) {
|
||||||
if (account.getStatus().isAttemptReconnect()) {
|
return false;
|
||||||
|
}
|
||||||
if (!hasInternetConnection()) {
|
if (!hasInternetConnection()) {
|
||||||
account.setStatus(Account.State.NO_INTERNET);
|
account.setStatus(Account.State.NO_INTERNET);
|
||||||
if (statusListener != null) {
|
|
||||||
statusListener.onStatusChanged(account);
|
statusListener.onStatusChanged(account);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (account.getStatus() == Account.State.NO_INTERNET) {
|
if (account.getStatus() == Account.State.NO_INTERNET) {
|
||||||
account.setStatus(Account.State.OFFLINE);
|
account.setStatus(Account.State.OFFLINE);
|
||||||
if (statusListener != null) {
|
|
||||||
statusListener.onStatusChanged(account);
|
statusListener.onStatusChanged(account);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (account.getStatus() == Account.State.ONLINE) {
|
if (account.getStatus() == Account.State.ONLINE) {
|
||||||
synchronized (mLowPingTimeoutMode) {
|
synchronized (mLowPingTimeoutMode) {
|
||||||
long lastReceived = account.getXmppConnection().getLastPacketReceived();
|
long lastReceived = account.getXmppConnection().getLastPacketReceived();
|
||||||
|
@ -939,12 +936,12 @@ public class XmppConnectionService extends Service {
|
||||||
} else {
|
} else {
|
||||||
pingCandidates.add(account);
|
pingCandidates.add(account);
|
||||||
if (isAccountPushed) {
|
if (isAccountPushed) {
|
||||||
pingNow = true;
|
|
||||||
if (mLowPingTimeoutMode.add(account.getJid().asBareJid())) {
|
if (mLowPingTimeoutMode.add(account.getJid().asBareJid())) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": entering low ping timeout mode");
|
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": entering low ping timeout mode");
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else if (msToNextPing <= 0) {
|
} else if (msToNextPing <= 0) {
|
||||||
pingNow = true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode());
|
this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode());
|
||||||
if (mLowPingTimeoutMode.remove(account.getJid().asBareJid())) {
|
if (mLowPingTimeoutMode.remove(account.getJid().asBareJid())) {
|
||||||
|
@ -977,8 +974,7 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
return pingNow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleSoftDisabled(final boolean softDisabled) {
|
private void toggleSoftDisabled(final boolean softDisabled) {
|
||||||
|
|
Loading…
Reference in a new issue