diff options
author | Christian S <christian@pix-art.de> | 2016-04-15 22:02:52 +0200 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2016-04-15 22:02:52 +0200 |
commit | 115a3a3396ac608a1ba855ab72a2ed5ecf28dc29 (patch) | |
tree | b5862a7ffaa9bdd15661f636669778ace05b6b7c /src/main/java/eu/siacs/conversations/services | |
parent | 26850fe48b1c772cb078276c3e8b4287689d17b6 (diff) | |
parent | e9494af098e6d3dad4f0a5328ae7342664ce853c (diff) |
Merge remote-tracking branch 'refs/remotes/siacs/master' into development
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index d6866ed45..1db65b486 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -509,7 +509,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } return START_STICKY; case Intent.ACTION_SHUTDOWN: - logoutAndSave(); + logoutAndSave(true); return START_NOT_STICKY; case ACTION_CLEAR_NOTIFICATION: mNotificationService.clear(); @@ -783,12 +783,16 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa public void onTaskRemoved(final Intent rootIntent) { super.onTaskRemoved(rootIntent); if (!getPreferences().getBoolean("keep_foreground_service", false)) { - this.logoutAndSave(); + this.logoutAndSave(false); } } - private void logoutAndSave() { + private void logoutAndSave(boolean stop) { + int activeAccounts = 0; for (final Account account : accounts) { + if (account.getStatus() != Account.State.DISABLED) { + activeAccounts++; + } databaseBackend.writeRoster(account.getRoster()); if (account.getXmppConnection() != null) { new Thread(new Runnable() { @@ -799,8 +803,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa }).start(); } } - Log.d(Config.LOGTAG, "good bye"); - stopSelf(); + if (stop || activeAccounts == 0) { + Log.d(Config.LOGTAG, "good bye"); + stopSelf(); + } } private void cancelWakeUpCall(int requestCode) { |