Change summary
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 9
1 file changed, 5 insertions(+), 4 deletions(-)
Detailed changes
@@ -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 {