When does syncthing synchronize while android is sleeping?

I discovered that connection to my android phone is not reliable while the phone is sleeping. It is sometimes disconnected and connected.

When does syncthing synchronize while my android phone is sleeping?

I made syncthing-android ignore battery optimization, but I haven’t turned on wakelock because wakelock drains battery.

Whenever the os decides to run the app, if it decides to run it that is.

You can try to whitelist the app as doze exemption manually by adb command. More info about this is on the wiki. For Android 7.0, I never found a solution as doze was there on the most aggressive level.

adb shell dumpsys deviceidle whitelist PKG_NAME

I use LineageOS 14.1 which is the same as android 7.0.

As far as I know, doze wakes up apps in batches on a regular basis.

Yes that’s right in case apps register for the wake up. SyncthingNative is a Linux binary so it can’t tell the Java world to wake up using Android methods. Some time ago I thought about a solution with jobscheduler , that would raise min API level higher and cause the app to be incompatible with older Android versions. Since Android 7.1 the behavior is better again what leaves me unsure if it’s worth to try the scheduler solution just for a single Android version.

If you used jobscheduler, what would be the lowest supported version of android?

Google? I need to look it up too, sorry.

jobscheduler is added to API level 21 which is android 5.0

1 Like

Ok terminating Android 4.x since release (tbd) could be done as it’s very old. Here’s another workaround: Enter tcp4://phone_ip_addr on the computer’s syncthing instance. Does it help? (Confirmed working on Huawei devices)

Connecting syncthing to an IP address isn’t going to change doze maintenance windows.

https://www.bignerdranch.com/blog/diving-into-doze-mode-for-developers/ describes doze mode and how to deal with it.

We are exempting from doze and thus don’t need those maintenance windows. Hmm I recall your GitHub name crocket, so we’d already had a long discussion about this doze issues.

SyncthingNative (go process) is about continuous file synchronization so will not fit your approach of letting it work in an Android defined maintenance window as there nothing would take care of starting or stopping the binary correctly.

I merely want to control and predict when syncthing-android becomes disconnected.

For now, it becomes disconnected randomly.

As a last resort, try upgrading Android to 8+ . (Should be available for your lineageos)

Yo, man. After I disabled battery optimization and enabled partial wakelock in syncthing-android, syncthing doesn’t disconnect randomly.

The simplest explanation is that the Go process doesn’t sleep if it inherits partial Doze exemption and partial wakelock from syncthing-android.

It seems partial wakelock is the only reliable way to keep the connection alive. Disabling battery optimization has little or no effect on connection reliability.

With partial wakelock, disabling battery optimization is unnecessary. Disabling battery optimization has no visible effect on connection reliability.

I suspect that syncthing does its work in doze maintenance windows without partial wakelock.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.