don't reconnect accout when system reports no internet connection

This commit is contained in:
Daniel Gultsch 2016-12-10 13:20:05 +01:00
parent 55b60f6b0f
commit 75ee14cfdf

View file

@ -2898,7 +2898,8 @@ public class XmppConnectionService extends Service {
connection = createConnection(account); connection = createConnection(account);
account.setXmppConnection(connection); account.setXmppConnection(connection);
} }
if (!account.isOptionSet(Account.OPTION_DISABLED)) { boolean hasInternet = hasInternetConnection();
if (!account.isOptionSet(Account.OPTION_DISABLED) && hasInternet) {
if (!force) { if (!force) {
disconnect(account, false); disconnect(account, false);
} }
@ -2909,10 +2910,13 @@ public class XmppConnectionService extends Service {
thread.start(); thread.start();
scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode()); scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
} else { } else {
disconnect(account, force || account.getTrueStatus().isError()); disconnect(account, force || account.getTrueStatus().isError() || !hasInternet);
account.getRoster().clearPresences(); account.getRoster().clearPresences();
connection.resetEverything(); connection.resetEverything();
account.getAxolotlService().resetBrokenness(); account.getAxolotlService().resetBrokenness();
if (!hasInternet) {
account.setStatus(Account.State.NO_INTERNET);
}
} }
} }
} }