feat(android) Check server is reachable before starting background backup #8989
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a check for android version that verifies that server is reachable before starting background backup and fail otherwise.
Why?
When server is behind VPN there is no reliable way to set constrains that would allow to start only for specific network.
This results in backup work tries that hang up in notifications.
One way to tackle this would be to start backup only when specific network is connected. Unfortunately it seems to be impossible when using VPN.
Another option is to check that server url can actually be reached before trying to run backup.
This PR tries to accomplish this by opening
HttpURLConnection
and checking for 200 code.Test?
Tested and confirmed on Android device.
Tested on iOS simulator that it doesn't break background backup start.