made foreground service logging more meaninful

This commit is contained in:
Daniel Gultsch 2018-09-13 18:47:57 +02:00
parent 98d772dab4
commit 724f86f054
1 changed files with 5 additions and 4 deletions

View File

@ -410,7 +410,6 @@ public class XmppConnectionService extends Service {
public void stopForcingForegroundNotification() { public void stopForcingForegroundNotification() {
mForceForegroundService.set(false); mForceForegroundService.set(false);
toggleForegroundService(); toggleForegroundService();
mNotificationService.dismissForcedForegroundNotification();
} }
public boolean areMessagesInitialized() { public boolean areMessagesInitialized() {
@ -1084,19 +1083,21 @@ public class XmppConnectionService extends Service {
} }
public void toggleForegroundService() { public void toggleForegroundService() {
final boolean status;
if (mForceForegroundService.get() || (Compatibility.keepForegroundService(this) && hasEnabledAccounts())) { if (mForceForegroundService.get() || (Compatibility.keepForegroundService(this) && hasEnabledAccounts())) {
startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification()); startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification());
Log.d(Config.LOGTAG, "started foreground service"); status = true;
} else { } else {
stopForeground(true); 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 @Override
public void onTaskRemoved(final Intent rootIntent) { public void onTaskRemoved(final Intent rootIntent) {
super.onTaskRemoved(rootIntent); super.onTaskRemoved(rootIntent);
//TODO check for accounts enabled
if ((Compatibility.keepForegroundService(this) && hasEnabledAccounts()) || mForceForegroundService.get()) { if ((Compatibility.keepForegroundService(this) && hasEnabledAccounts()) || mForceForegroundService.get()) {
Log.d(Config.LOGTAG, "ignoring onTaskRemoved because foreground service is activated"); Log.d(Config.LOGTAG, "ignoring onTaskRemoved because foreground service is activated");
} else { } else {