Catfriend1 / syncthing-android

Syncthing-Fork - A Syncthing Wrapper for Android.
Mozilla Public License 2.0
1.2k stars 40 forks source link

Input validation for the number of minutes #1014

Closed opk12 closed 11 months ago

opk12 commented 11 months ago

Description of the issue

The sync cycle setting allows for 999999999999999999999 minutes, then the app crashes on launch.

FATAL EXCEPTION: main
Process: com.github.catfriend1.syncthingandroid, PID: 25716
java.lang.RuntimeException: Unable to resume activity {com.github.catfriend1.syncthingandroid/com.nutomic.syncthingandroid.activities.MainActivity}: java.lang.NumberFormatException: For input string: "999999999999999999999"
...
Caused by: java.lang.NumberFormatException: For input string: "999999999999999999999"
...
    at com.nutomic.syncthingandroid.service.RunConditionMonitor.updateShouldRunDecision(RunConditionMonitor.java:370)
    at com.nutomic.syncthingandroid.service.SyncthingService.evaluateRunConditions(SyncthingService.java:753)
    at com.nutomic.syncthingandroid.activities.MainActivity.onResume(MainActivity.java:347)
...

Version Information

1.23.6.0 from F-droid

Catfriend1 commented 11 months ago

What is the max value not throwing an error?

opk12 commented 11 months ago

RunConditionMonitor.java:370 calls Integer.parseInt(), so I think 2147483647 as defined in the JLS.

I'm a very new user and I'm trying to have Syncthing sleep until called manually, as it noticeably slowed down the phone and drained battery (Samsung Android 7.1), I had to uninstall it, until I get spare time to test settings again. If the "right" way is to set a huge number (not sure about that) then the number could be auto-capped to the max (rather than, say, rejected)?

Catfriend1 commented 10 months ago

Please report back if it's solved by https://github.com/Catfriend1/syncthing-android/releases/tag/v1.26.0.0 . Thank you.