From 724f86f054828ed29048d20698766d98329c9a15 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 13 Sep 2018 18:47:57 +0200 Subject: [PATCH] made foreground service logging more meaninful --- .../conversations/services/XmppConnectionService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 460c7c6ab..83ced6879 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -410,7 +410,6 @@ public class XmppConnectionService extends Service { public void stopForcingForegroundNotification() { mForceForegroundService.set(false); toggleForegroundService(); - mNotificationService.dismissForcedForegroundNotification(); } public boolean areMessagesInitialized() { @@ -1084,19 +1083,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 {