I create an WifiNetwork class that holds information about Wifis networks.
I have the method:
public static WifiNetwork fromScanResult(ScanResult scanResult) {
String capabilities = scanResult.capabilities;
String ssid = scanResult.SSID;
String bssid = scanResult.BSSID;
int frequency = scanResult.frequency;
int level = scanResult.level;
long timestamp = 0L;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
timestamp = scanResult.timestamp;
}
return new WifiNetwork(capabilities, ssid, bssid, frequency, level, timestamp);
}
That converts an ScanResult into my object.
I need another method populate my object from a WifiInfo:
public static WifiNetwork fromWifiInfo (WifiInfo wifiInfo){
....
}
The WifiInfo object is obtained by:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
wifiManager.getConnectionInfo()
From ScanResult, the security mode (if the network is WEP, WAP, etc) is getted by scanResult.capabilities();
But I cannot see an equivalent in WifiInfo.
Is there another way to get the security mode from the active Wifi Connection?