-
Notifications
You must be signed in to change notification settings - Fork 190
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Android 10 support. Testers needed #47
Comments
Does it have a way to connect to Wifi network as I've written here: |
@AndroidDeveloperLB I haven't tried the root way because that's another story that involves some command line arguments plus I'm not even sure if it's gonna work. The new contribution aims to make this library connect to WiFi networks on Android 10 devices without requiring root but it's not thoroughly tested yet. |
@ThanosFisherman Wait you have an idea of what should be done using root?
|
That is correct, with the new api (starting Android 10), the wifi internet is only for the app that requested it. I assume the use case is more like connecting to configure IoT devices. |
@eliaslecomte Well it's not such a nice alternative to what we had before... |
I believe that they're trying to prevent MITM attacks by not allowing an app to connect to a subverted access point. They don't explicitly say that because you never want to give attackers suggestions. |
" subverted access point" ? |
No, that's why an application can't connect without recommending the connection to the user. |
What I say is that without COARSE_LOCATION and FINE_LOCATION permissions, it's still possible to get a good guess of where you are, so that's why I think they added those into the mix. |
Yes, you are quite correct. So rather than leave the user in the dark, they require scanning for WiFi access point to have location permissions. The user gets explicitly asked for that. |
I tried implementing the same in a new project. The phone connects and instantly disconnects to the network, as the OnAvailable method of the NetworkCallback seems to be in a loop. Demo video |
@singhal2 Can you please share the source code of this? |
What network security is used (wpa2?)? |
WPA2 and with internet. I’ll upload a sample soon.
…Sent from my iPhone
On 4 Feb 2020, at 09:02, Elias Lecomte ***@***.***> wrote:
I tried implementing the same in a new project. The phone connects and instantly disconnects to the network, as the OnAvailable method of the NetworkCallback seems to be in a loop. Demo video
What network security is used (wpa2?)?
Is it a network with or without internet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@singhal2 If you can make it happen even without this library, you should report it to Google: |
Here is the source code I implemented. It contains both the library and standard code to connect to wifi. |
@singhal2 Probably wrong link. Doesn't include Android app project... |
There is a first problem: setWifiEnabled always returns false. I didn't have this at first, not sure if this is due to an sdk patch update? |
@eliaslecomte You mean this: https://developer.android.com/reference/android/net/wifi/WifiManager.html#setWifiEnabled(boolean)
You can't normally toggle Wifi using this permission anymore. Maybe via other workarounds (root, being system app, etc...). |
Yes, but also, startScan returns false starting Android 10 if you request ACCESS_COARSE_LOCATION. Will have to add a description for that. As documented here: https://developer.android.com/guide/topics/connectivity/wifi-scan |
@eliaslecomte I hope you figure it out. Such a mess has become of Android API. Too many restrictions, that sometimes even the docs don't help. |
Based on Wifitutils 1.5.1, I have tested on XiaoMi Mix2 (android 10). It can connect to a WIFI of IoT(can not access the internet). but the IP looks wired. after I add connctionManager.bindProcessToNetwork, it works. But to support disconnect from that WIFI, I need to pass out the networkCallback used in connectivityManager.requestNetwork(request, networkCallback) when connecting to wifi. I did not see there is any interface can do that. so I create a Pull Request on react-native-wifi-reborn |
@ljbatwh The latest version (1.6.0) of WifiUtils includes support for disconnecting of wifi networks. Please take a look at MainActivity to see how disconnection works and do some testing on your Xiaomi because I do not own an android 10 device yet. |
@ThanosFisherman thanks. the 1.6.0 can connect and disconnect wifi on my android 10 (XiaoMi Mix2)
|
@ljbatwh I've added the bindProcessToNetwork() again(it was also in 1.5.0 but I wrongly assumed it wasn't needed because my IoT device does not have internet) in this pr: #66. I would assume multicast works. I am also using https://github.com/tradle/react-native-udp and this works after connecting with bindProcessToNetwork(). |
@ThanosFisherman I tried multiple time, I debug my a lot of code too, so the scope of internet access is limited inside the app, If you leave the app which you trigger the connection to a hotspot, then, you will not have internet access. |
Yes this is actually normal behavior. Since Android 10, Android has blocked the previous api's to manipulate wifi configuration entries. There are 2 new api's. The first (which is currently used by WifiUtils) is used for IoT commissioning. The app that uses it can execute api calls to the wireless access point. Only that app, and the wifi network is not persisted for the smartphone to use. There is also a wifi suggestion api in Android. You might have need to have a look at that. |
@eliaslecomte and sample what is solution ??? how use library with android 10 ??? |
Hi @ThanosFisherman If i provide correct password, then it connected and I save this password. After that, even the correct password doesn't works, always showing above Log. what can i do? remove(SSID, callback) function is forgetting previous configuration in Android 10?, if not how??? Hope any one can give me answer asap. |
Did you maybe edit the MainActivity? This file is no longer used, you should edit the MainKotlinActivity for testing purposes. |
If changing password / reconnecting doesn't work you will have to debug. I think it will be a phone firmware issue rather than something WifiUtils can fix. |
Thanks @eliaslecomte
it will work again if i go to wifi settings and forgot that wifi. Hope your kind reply, Thanks. |
PS; the password is changed correctly in Firmware, if i fresh wifi and try changed password, it works. |
Is your app targetting Android 10? If that's the case it's not actually saving the wifi configuration. You can only Disconnect in wifi settings but it's never saved in the first place. I would call the remote method first. |
min sdk version is 23, targetSDK version is 29 |
Regarding the sample I did some cleanups, migrated to .kts gradle scripts, renamed the @super0610 Seems like another restriction (or probably a bug on Android OS itself). You say that if you manually forget the network then WifiUtils are able to reconnect with the new password. Please Try the following:
|
Thanks for your reply @ThanosFisherman |
hi @ThanosFisherman |
in Android 7, sample works. |
Thanks for the update @super0610 I'm not sure yet what might be wrong or if this is an intended behavior. I'll try to investigate it and post back. |
Thanks @ThanosFisherman |
I'm not having a Samsung SM-T290, so I can't help on this one. If you could do any more debugging @super0610 that would be awesome. |
Getting Error COULD_NOT_SCAN in android 10 when connecting to local hotspot created with specific ssid and password |
Same here. Galaxy S20 connecting to a device that doesn't have an internet connection with a specific ssid and password. edit: could be an S20 specific issue. I am able to connect to the same WiFi network using Google Pixel 4a on AN10 edit 2: location was turned off on the S20. Turned it on and was able to connect |
I have found an application and it can easily connect to wifi on android 10 device.But I don't know how it work. |
About enabling/disabling Wifi through the library on Android 10 (and up) - I think because of the OS restrictions that have been put in place the best option would be to invoke a Settings panel:
What do you think? |
This is logic you want to add in your app :-). The library indicates wifi is off. You show this 'error state' and the user has to take action. You can add a button that then opens the Settings screen. |
I tried it on my Android 10 device and I get zero scanResults. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Please report any connectivity issues related to Android 10 here.
WiFiUtils now has a basic support for Android 10 thanks to the contribution #46 of @eliaslecomte
Hopefully owners of Android 10 devices will help us fix potential bugs.
The text was updated successfully, but these errors were encountered: