I need to get security type from WifiConfiguration
entry. Is it possible?
String getSecurityType(WifiConfiguration conf) {
}
returning values "NONE", "WEP", "WPA", "WPA2"
For those who think it's a duplicate question: I want to get information from WiFiConfiguration
object and not from ScanResult
object. It's not the same!
How to Check Your Wi-Fi Security Type in Android. To check on an Android phone, go into Settings, then open the Wi-Fi category. Select the router you're connected to and view its details. It will state what security type your connection is.
Using WPA2-Personal (PSK)Once you find the wireless security settings, select WPA2 security and AES encryption. Then enter a Pre-Shared Key or Passphrase of 8 to 63 alphanumeric characters. The longer and more complex the more secure. Try to upper and lower case letters and numbers.
To enable WPA3-Personal, WPA3-Enterprise, and Wi-Fi Enhanced Open in the Android framework: WPA3-Personal: Include the CONFIG_SAE compilation option in the wpa_supplicant configuration file. WPA3-Enterprise: Include the CONFIG_SUITEB192 and CONFIG_SUITEB compilation options in the wpa_supplicant configuration file.
I can do it, simply:
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
import android.net.wifi.WifiConfiguration.KeyMgmt;
public static final int SECURITY_NONE = 0;
public static final int SECURITY_WEP = 1;
public static final int SECURITY_PSK = 2;
public static final int SECURITY_EAP = 3;
public static int getSecurity(WifiConfiguration config) {
if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK))
return SECURITY_PSK;
if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X))
return SECURITY_EAP;
return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE;
}
so...
public static String getSecurityType(WifiConfiguration config) {
switch (getSecurity(config)) {
case SECURITY_WEP:
return "WEP";
case SECURITY_PSK:
if (wifiConfiguration.allowedProtocols.get(WifiConfiguration.Protocol.RSN))
return "WPA2";
else
return "WPA";
default:
return "NONE";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With