avoid unnecessary disconnect. prevent NetworkOnMainThreadException
This commit is contained in:
parent
c9e4b332bf
commit
4cb2d0ca93
|
@ -2554,9 +2554,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {
|
private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {
|
||||||
synchronized (account) {
|
synchronized (account) {
|
||||||
XmppConnection connection = account.getXmppConnection();
|
XmppConnection connection = account.getXmppConnection();
|
||||||
if (connection != null) {
|
if (connection == null) {
|
||||||
disconnect(account, force);
|
|
||||||
} else {
|
|
||||||
connection = createConnection(account);
|
connection = createConnection(account);
|
||||||
account.setXmppConnection(connection);
|
account.setXmppConnection(connection);
|
||||||
}
|
}
|
||||||
|
@ -2570,6 +2568,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!force) {
|
if (!force) {
|
||||||
|
disconnect(account, false);
|
||||||
try {
|
try {
|
||||||
Log.d(Config.LOGTAG, "wait for disconnect");
|
Log.d(Config.LOGTAG, "wait for disconnect");
|
||||||
Thread.sleep(500); //sleep wait for disconnect
|
Thread.sleep(500); //sleep wait for disconnect
|
||||||
|
@ -2582,6 +2581,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
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.getRoster().clearPresences();
|
account.getRoster().clearPresences();
|
||||||
connection.resetEverything();
|
connection.resetEverything();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue