aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-09-23 16:57:47 +0200
committerChristian Schneppe <christian@pix-art.de>2018-09-23 16:57:47 +0200
commit33f7d5cd9a0e6fb1fb8e75fa5410365935ab1af5 (patch)
tree6970cdf36cad234be99f38610c63692331d77070 /src/main/java/de/pixart/messenger/services/XmppConnectionService.java
parent032466bb9936099fa9164dd733bc264739edc7fb (diff)
made foreground service logging more meaninful
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java11
1 files changed, 6 insertions, 5 deletions
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()) {