syncthing-android
syncthing-android copied to clipboard
Unreliable charging detection
My "Run Conditions": run on any Wi-Fi + only on AC. Tested on: Galaxy S10+ on stock Android 11, Galaxy S5 on Android 10 LineageOS.
On both devices AC vs battery detection logic is extremely unreliable, every now and then it goes to inverted state, i.e. syncthing service is being started when disconnected from power and being killed when connecting to AC.
Validated by running "logcat | grep -E 'RunConditionMonitor|SyncthingService|BatteryService'" in wireless ADB shell and plugging AC powersupply in and out repeatedly.
Looking at the RunConditionMonitor.java and logcat output, here is my guess: ACTION_POWER_CONNECTED and ACTION_POWER_DISCONNECTED are being received just fine and then code is trying to process BatteryManager.EXTRA_PLUGGED value, which is a bad idea to do instantly, since a lot of times battery status hasn't updated yet.
Quick google returned similar issue: https://stackoverflow.com/a/11868558
Perhaps this call to updateShouldRunDecision() should be fired async, schedule it for execution in a few seconds, let the battery status settle first. https://github.com/syncthing/syncthing-android/blob/00edf5f868512301ec770caeb5d07081dba3f1d1/app/src/main/java/com/nutomic/syncthingandroid/service/RunConditionMonitor.java#L121
Same issue as #1540 and #1574
This issue is fixed in fork, pulling this one-line commit would fix it for official build as well
Catfriend1/syncthing-android@0cd20ff4de68fac9511eb0670eb858007ba89723
Hi, any chance of including this fix? Thanks!
Yes include it, please.
Thank you!