syncthing / syncthing-android

Wrapper of syncthing for Android.
https://syncthing.net/
Mozilla Public License 2.0
3.46k stars 390 forks source link

Allow Syncthing to run in foreground but not background when "Respect Android battery saving" is enabled #1294

Open peey opened 5 years ago

peey commented 5 years ago

What Happened

I had enabled the "Respect Android Battery Saving" setting. I opened Syncthing to synchronize one change. I was greeted with the prompt "Syncthing is disabled" (screenshot below)

image

I couldn't access the app till I either disable the setting or disable the battery saving. Only other option is to exit the app.

What you expected to happen instead

In general, the power saving setting curbs background usage of data by apps but never affects apps running in foreground. Syncthing should conform to this expectation and be able to run in the foreground even with this setting enabled.

Version Information

App Version: 0.10.19
Android Version: Android 9.0

Related Issues

https://github.com/syncthing/syncthing-android/issues/973 is a similar issue but it was more of a question, it wasn't asking for syncthing app to change its behavior.

AudriusButkevicius commented 5 years ago

Well if you change the settings it will run in the foreground. Not sure I follow the request.

peey commented 5 years ago

If I change the setting it'll also run in the background

AudriusButkevicius commented 5 years ago

No it won't if you disable run as service on startup.

peey commented 5 years ago

Run as service is already disabled on startup

AudriusButkevicius commented 5 years ago

Right, so disable the "dont run on power save" run condition and it will run in foreground.

peey commented 5 years ago

Yes, but then it also runs in the background. Is there a setting already which addresses the issue I've mentioned?

Allow Syncthing to run in foreground but not background

AudriusButkevicius commented 5 years ago

If its not setup as a service it only runs when the app is open.

Catfriend1 commented 5 years ago

Seems there is nothing to fix here ..

peey commented 5 years ago

If you switch away from the app, or even remove it from recent apps it still keeps running in the background.

If you're on power saver mode you wouldn't want this?

AudriusButkevicius commented 5 years ago

Not for me, so you either have it setup to run as a service or some weirdness with your os.

peey commented 5 years ago

Alright. I guess someone else will have to confirm if it affects them. Happy to provide steps to reproduce.

Configuration: "run on startup" is disabled, "respect android battery saving setting" is disabled as you suggested so you can use app in the foreground

  1. Open the app
  2. Switch away. The "syncthing is running" notification stays.
  3. Remove the app from "recent apps", the "syncthing is running" notification still stays

App version and OS version given in original comment.

imsodin commented 5 years ago

If its not setup as a service it only runs when the app is open.

Not for me on Android 7.1: When I opened the app (not having checked "Start service automatically on boot") and then switch to another app and remove it from the recent apps view, Syncthing keeps running. The only way to stop it is to click exit in the app menu. And that's actually the behaviour I would expect and want: I don't want to have Syncthing open while it syncs, but neither do I want it to run always when my phone is running (start on boot). To me it sounds like this is a "feature request" to stop Syncthing when the app is not in foreground (and not running as a service) and the global android battery saver option is enabled.

peey commented 5 years ago

I don't want to have Syncthing open while it syncs, but neither do I want it to run always when my phone is running

This is true in general, but if you're in power saving mode then you would want it.

To me it sounds like this is a "feature request" to stop Syncthing when the app is not in foreground (and not running as a service) and the global android battery saver option is enabled.

Yeah I suppose. I thought the "respect battery saving settings" function was supposed to do this. Because otherwise I'm wasn't sure what it did. Now I understand that it's perhaps only useful if you have startup on boot enabled.

capi commented 5 years ago

I think there is a general misunderstanding: if you disable "automatically run in background" it will start, once you open the app. THEN it will continue running until you select "Exit" right in the bottom of the left sidebar. It delegates the responsibility for starting and stopping to you.

That said, it still needs to satisfy the run conditions and will stop if they are violated. And re-start once they are fulfilled again. The first start after reboot is up to you. And it will stop running, if you select "Exit".

arodland commented 5 years ago

What most people want is pretty simple and completely orthogonal to the "run at startup" setting. We want a quick way to defeat the run controls, without permanently changing the run control settings, so that we can sync something right now. One way to accomplish this would be to say that the daemon runs whenever the GUI is open, irrespective of the run controls. Another way would make use of the box that pops up right now when you open the GUI that says "syncthing is disabled" and gives you a chance to edit the settings. What you could do would be to add a "start, and run until I close the app" button to that box, which would do exactly what it said.

capi commented 5 years ago

@arodland The problem is the "until I close the app" is not so well defined on Android. But yes, for my personal use-case I have a locally applied patch that allows me to change settings via Tasker, so that I can enable syncing on battery for 5 minutes once I get home. The mechanism could be extended to something like that. Hopefully I'll find time to work on that in the nearer future and contribute it back to the project.