diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-03-03 13:31:59 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-03-03 13:31:59 +0100 |
commit | 4cb2d0ca932de2bb387c5f843ad6df608b04c03b (patch) | |
tree | 29cbc83a04624d8af05d691af04ca3af19a3e701 | |
parent | c9e4b332bfd1b8ddf91f3b1017cfca936ba9cbec (diff) |
avoid unnecessary disconnect. prevent NetworkOnMainThreadException
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 07a7e10b..cc269b67 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2554,9 +2554,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa private void reconnectAccount(final Account account, final boolean force, final boolean interactive) { synchronized (account) { XmppConnection connection = account.getXmppConnection(); - if (connection != null) { - disconnect(account, force); - } else { + if (connection == null) { connection = createConnection(account); account.setXmppConnection(connection); } @@ -2570,6 +2568,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } } if (!force) { + disconnect(account, false); try { Log.d(Config.LOGTAG, "wait for disconnect"); Thread.sleep(500); //sleep wait for disconnect @@ -2582,6 +2581,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa thread.start(); scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode()); } else { + disconnect(account, force); account.getRoster().clearPresences(); connection.resetEverything(); } |