From 33f7d5cd9a0e6fb1fb8e75fa5410365935ab1af5 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 23 Sep 2018 16:57:47 +0200 Subject: made foreground service logging more meaninful --- .../de/pixart/messenger/services/XmppConnectionService.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main/java/de/pixart/messenger/services/XmppConnectionService.java') diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index b46c2f606..25d4fb2b8 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -431,7 +431,6 @@ public class XmppConnectionService extends Service { public void stopForcingForegroundNotification() { mForceForegroundService.set(false); toggleForegroundService(); - mNotificationService.dismissForcedForegroundNotification(); } public boolean areMessagesInitialized() { @@ -1233,19 +1232,21 @@ public class XmppConnectionService extends Service { } public void toggleForegroundService() { + final boolean status; if (mForceForegroundService.get() || (Compatibility.keepForegroundService(this) && hasEnabledAccounts())) { startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification()); - Log.d(Config.LOGTAG, "started foreground service"); + status = true; } else { stopForeground(true); - Log.d(Config.LOGTAG, "stopped foreground service"); + mNotificationService.dismissForcedForegroundNotification(); //if the channel was changed the previous call might fail + status = false; } + Log.d(Config.LOGTAG, "ForegroundService: " + (status ? "on" : "off")); } @Override public void onTaskRemoved(final Intent rootIntent) { super.onTaskRemoved(rootIntent); - //TODO check for accounts enabled if ((Compatibility.keepForegroundService(this) && hasEnabledAccounts()) || mForceForegroundService.get()) { Log.d(Config.LOGTAG, "ignoring onTaskRemoved because foreground service is activated"); } else { @@ -2670,7 +2671,7 @@ public class XmppConnectionService extends Service { private boolean hasEnabledAccounts() { if (this.accounts == null) { - return true; // set to true if accounts could not be fetched - used for notifications + return false; // set to false if accounts could not be fetched - used for notifications } for (Account account : this.accounts) { if (account.isEnabled()) { -- cgit v1.2.3