Coupling syncing to Android's sync setting

Hey,

how difficult would it be to sync Syncthing’s syncing to Android’s sync setting? Wow, that were a lot of "sync"s.

For example, I do not always need my e-mails to be up to date. That’s when I turn syncing off in Android. It would be nice if this also stops any Syncthing syncing.

I hope this is not too confusing.

Cheers!

You mean when Syncthing is disabled on your phone, the Syncthing instance on your PC should also be disabled?

You could check the api for number of connections, and shut down Syncthing if there are no connections. But there’s no way to know when to start it again.

I think he means that Syncthing Android should also kill syncthing when the setting in “Data usage” -> menu -> “Limit Background Data” is set (And restart when it is unset).

It seems that his Android version calls it something else.

You can also pause all devices, rather than shutting down Syncthing completely.

Okay, apparently that was too confusing. I meant the Android system wide syncing that can e.g. be toggled from Settings>Accounts>Hamburger Menu>“Auto sync data” in Marshmallow. There is also a quick settings toggle for that. K-9 Mail for example only syncs its email accounts when this switch is enabled, despite not having an account set at Settings>Accounts. If this setting can somehow be accessed, we could implement another switch in Syncthing besides “Sync only when charging” and “Sync only in these networks”: “Sync only when Android Auto Sync is on”. Clearer now?

1 Like

Right, I completely misunderstood your post.

It seems possible to implement, but doesn’t really seem to make sense. The thing is, sync settings only work per account, so we’d have to add a “Syncthing account” to Android. And that just doesn’t make sense, because you can’t login to Syncthing in the same way you do for Google, Facebook etc.

I think it would be better to have a global pause button in the app instead, that pauses all transfers. See #254.

But if there’s multiple users on a device, perhaps there’s multiple syncthings too? (How to fill up device memory even faster and create even more contention for use of Daddy’s tablet.) But really, maybe it can make an account automatically since it’s mostly a dummy account just to hook into the global sync setting?

I think the pause all button should exist but it makes more sense to me if the global sync setting can be tied to Syncthing for this use case. Otherwise there are multiple places a user has to turn of Sync to stop all of their accounts.

I guess it would make sense to have both. Actually, integrating with the system sync settings should also give us automatic pausing if the battery is low, that would be nice.

Can you or @murpledurple open an issue on Github for this? Then someone just needs to implement it :smiley:

Opened, #588

Thanks a lot!

K-9 Mail also manages to access the sync setting without having any accounts set up via Android’s account settings. Maybe we can have a peek at their source code? Unfortunately my code-fu is almost non-existent, so I’m not really of any use here. Sorry!

Where do you see the K-9 sync settings? I just checked the Android account settings, and it’s not there (I have an account configured).

In K9-Mail it’s in Global Settings -> Network -> Background Sync.

1 Like

Thanks @wweich, that was fast

But that doesn’t integrate with the Android sync settings, right? It’s the same thing I proposed, having a setting in the app.

It does! When global Android sync is turned off, K-9 Mail displays “Syncing disabled” in its account view.

[edit] Also, that would be my preferred way of handling it: An additional setting in the app that hooks onto Android’s sync setting. Like I described in my second post, Coupling syncing to Android’s sync setting.

1 Like

The K9-Mail setting won’t add an account in the Android accounts, but will respect the global sync setting in the acount settings.

I just tested it. If you set K9-Mail Background Sync to When 'Automatic Sync' is active it will disable the sync if you disable the global sync in the account settings.

2 Likes

That’s what I mean, thanks!

Could you open an issue for this please?

@kluppy already opened one: