ThanosFisherman / WifiUtils

Easily Connect to WiFi Networks
Apache License 2.0
731 stars 188 forks source link

Suggestion: bind to WiFi network on lower SDK versions #91

Open asantana48 opened 3 years ago

asantana48 commented 3 years ago

At the moment, WifiUtils only binds to WiFi networks on Android 10 so API calls are performed over the specified network. For non-Android 10, it seems sufficient most of the time to disable all other configurations and just enable the configuration we want. However, a coworker (using OnePlus 5T, Android 8.1) has recently reported an issue where sometimes an API call will reach our hardware, but other times will raise a SocketTimeoutException. I'm confident that this is because the call is trying to go through his mobile data since, if he turns it off, they reach the hardware as expected.

Can we bind to WiFi for every SDK level that it's supported? The bindProcessToNetwork call is SDK 23 and even pre-23 we can do setProcessDefaultNetwork(network) I believe.

I've already started work on this, but I thought I would ask what your thoughts are on this and if you would be interested in a PR once I've confirmed that this fixes our issue.