tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+
https://www.npmjs.com/package/cordova-plugin-wifiwizard2
Apache License 2.0
123 stars 146 forks source link

Add support for API level 29 #104

Closed ViggoChavine closed 4 years ago

ViggoChavine commented 4 years ago

Description of the Change

  1. Java: adds support for API level 29 released with Android 10. Uses WifiNetworkSpecifier.Builder to establish a connection, and ConnectivityManager.unregisterNetworkCallback when disconnecting

  2. Javascript: does not add double apostrophe when Android platform 10 or above because the new method for connecting does not support it

Benefits

Able to use the plugin on Android devices having API level 29 or higher

Possible Drawbacks

According to our tests none. Changes are only applied for API version 29 and higher

arsenal942 commented 4 years ago

Looks good to me!

ViggoChavine commented 4 years ago

Remove all the random spaces

I have amended space removal fix into the existing commit to keep the history clean

danielehrhardt commented 4 years ago

Please merge

danielehrhardt commented 4 years ago

Looks good to me, I haven't been able to test myself but if others report this works I think it should be good to go

I tested on my Devices. Looks fine.

ducker commented 4 years ago

From this conversation I assume that PR is ready to merge and is waiting almost month to do it. Could you review and merge the changes as it is quite important feature to support latest android version?

favalex commented 4 years ago

I'm very new to android development, so take this with a pinch of salt. I've noticed that in many places API 29 will keep using wifiManager.getConfiguredNetworks() and that will always return an empty list according to documentation: https://developer.android.com/reference/android/net/wifi/WifiManager#getConfiguredNetworks()

This is causing many places to malfunction. For example mapping of SSID to network id doesn't work at all.

I can give you more details, in case you confirm that this is indeed a problem and not just me badly misunderstanding the code.

eliadAfeka commented 4 years ago

is there any news with this PR ? in November 2020 will no longer have the option to use this plugin without this PR.

markarupert commented 4 years ago

Does this fix work for anyone? I tried connecting to my network (in this case a wifi enabled device that is not on the internet) and a box pops up like it is trying to ask me if I want to connect to it but nothing is in the list.

Is there anyway for this to happen in the background, or have the user give it permission to connect without asking the next time?

VijayVaveHealth commented 4 years ago

@markarupert unfortunately no way to get rid of the box, please take a look at this https://blog.ostebaronen.dk/2019/11/android-10-wifi.html

If you are looking at connecting to an iOT device with no internet i have a forked version of ViggoChavine's branch that adds that support, please look at that.

saoron commented 4 years ago

@VijayVaveHealth what's the changes you made that are specific for internetless IOT?

VijayVaveHealth commented 4 years ago

@saoron this is what i have in my network request builder

NetworkRequest.Builder networkRequestBuilder1 = new NetworkRequest.Builder(); networkRequestBuilder1.addTransportType(NetworkCapabilities.TRANSPORT_WIFI); networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); networkRequestBuilder1.addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED); networkRequestBuilder1.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED); networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN); networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_FOREGROUND); networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED); networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED); networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING); networkRequestBuilder1.setNetworkSpecifier(wifiNetworkSpecifier);

mrelis commented 4 years ago

Pending reviewer @arsenal942, please review & approve :-)

glenngr commented 4 years ago

Looks like @arsenal942 first approved, but then reset the vote because some changes were requested.

@tripflex are you able to remove @arsenal942 as a reviewer, ping him to approve, or force approve this PR?

Rytiggy commented 4 years ago

After that my app worked as expected with android sdk 29+.

tripflex commented 4 years ago

Sorry guys, so little time to work on this stuff, merging!

Fred-Reis commented 3 years ago

https://github.com/tripflex/WifiWizard2/pull/104#issuecomment-710535132

works fine for me