WPA2-EAP & WPA3-EAP stopped working on Android 13 and above

313 views Asked by At

If I'm posting in the wrong forum, please kindly point me to the right direction.

The same following codes worked for devices up to Android 12 has stopped working on 13 and above.

//partial environment settings
compileSdkVersion 33
buildToolsVersion "30.0.3"
targetSdkVersion 28
//partial code
.....
val wifiManager =
applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager

val enterpriseConfig = WifiEnterpriseConfig()
enterpriseConfig.eapMethod = WifiEnterpriseConfig.Eap.PEAP
enterpriseConfig.phase2Method = WifiEnterpriseConfig.Phase2.MSCHAPV2
enterpriseConfig.identity = "test"
enterpriseConfig.password = "123456"
val config = WifiConfiguration()
config.SSID = "\"" + ssid + "\""
config.hiddenSSID = true

config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP)
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X)

config.enterpriseConfig = enterpriseConfig
val wcgID = wifiManager.addNetwork(config);
Log.d("WIFI", "wcgID:$wcgID")
wifiManager.disconnect()
val b: Boolean = wifiManager.enableNetwork(wcgID, true)
wifiManager.saveConfiguration()
wifiManager.reconnect()
Log.d("WIFI", "b:$b")
...

Connection cannot be made successfully on Android 13+,with “val wcgID = wifiManager.addNetwork(config);” it always gives you “-1”,devices on Android 12 and below all worked just fine.

Also, I found it works for connection types like PSK and WEP on Android 13+, just not EAP.

I tried to comment out the following lines, i.e. not configuring EAP and 802.1X:

//config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP)
//config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X)

When running "addNetwork", it doesn't give you "-1" anymore, but then it won't connect the target EAP-type SSID either.

I'm puzzled by this. Is it some configuration error or is Android 13+ simply doesn't support this method anymore? Are there better ways or workarounds to achieve this?

I would really appreciate it if anyone could shed some light on this!

Thanks in advance for your kindness and help!

0

There are 0 answers