Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android10 support to connect and disconnect network #66

Conversation

ljbatwh
Copy link

@ljbatwh ljbatwh commented Apr 22, 2020

Make connectToProtectedSSID and disconnect work on android 10
WifiUtils 1.5.1 can connect to wifi on android10.
but disconnect can not do by it.
on Android 10,
when connecting wifi, will call connectivityManager.requestNetwork(request, networkCallback);.
when disconnect from it, should call connManager.unregisterNetworkCallback(networkCallback);

But by WifiUtils, we can not pass out the networkCallback. and also it does not has API to disconnect from wifi. so without breaking change, it can not support disconnect both.
Because I am not very familiar with WifiUtils.
So I create a PR in here first.

@ljbatwh ljbatwh changed the title Android10 add suggestion network Android10 support to connect and disconnect network Apr 22, 2020
@eliaslecomte
Copy link
Collaborator

Hmm I did the implementation for WifiUtils and assumed the bindProcessToNetwork(network); was only required for networks without internet connectivity.

One advantage of doing this, if you forget to unregisterNetworkCallback is that the app suddenly can't access your mobile network anymore.

I will do some testing and can actually fix this via a change in WifiUtils. Or use WifiUtils 1.5.0 (which did this bind call).

@eliaslecomte eliaslecomte self-assigned this Apr 25, 2020
@eliaslecomte
Copy link
Collaborator

You have btw a bug in your code: you need to declare exec final.

@ljbatwh
Copy link
Author

ljbatwh commented Apr 30, 2020

@eliaslecomte thanks for the explanation why not add bindProcessToNetwork(network).
I also don't like hardcode the bindProcessToNetwork(network) in.
But I did not find a way to call this according to the situation because WifiUtils do not have a callback to let the client has an opportunity to call this.
I am not familiar with WifiUtils. so if you can tell me a way by which we can call the bindProcessToNetwork just after connecting to the network. I will very much appreciate.

@eliaslecomte
Copy link
Collaborator

eliaslecomte commented May 1, 2020

I've opened #74 and I am also pursuing this on the WifiUtils repo so we can correctly disconnect: ThanosFisherman/WifiUtils#66.

@ljbatwh
Copy link
Author

ljbatwh commented May 5, 2020

@eliaslecomte Thanks, I prefer your change instead of this PR because your change is more thoughtful. So I discard this PR

@ljbatwh ljbatwh closed this May 5, 2020
@jcarioti
Copy link

I've opened #74 and I am also pursuing this on the WifiUtils repo so we can correctly disconnect: ThanosFisherman/WifiUtils#66.

Does this mean that disconnecting from a bound network on Android is not currently working? I'm having issues with this exact problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants