Do any of you Android gurus out there know of any open source code to create a WifiConfiguration
from a given ScanResult
? It would be helpful. Indeed, line 483 (/624) of my capture (mid April 2012) of the Android source of WifiConfiguration.java
is a commented-out constructor intended to do exactly this, with a big TODO wondering whether it's worth implementing (see quote below). I motion yes, can I hear a second?
The main challenge I see (which is actually the brunt of this question) is how to interpret the ScanResult.configuration String.
[WPA2-PSK-CCMP]
, [WPS]
, etc?From WifiConfiguration.java
(with possible editorializing):
/**
* Construct a WifiConfiguration from a scanned network
* @param scannedAP the scan result used to construct the config entry
* TODO: figure out whether this is a useful way to construct a new entry.
*
public WifiConfiguration(ScanResult scannedAP) {
networkId = -1;
SSID = scannedAP.SSID;
BSSID = scannedAP.BSSID;
// aaaah screw it I'm tired/lazy
}
*/
I found this project https://github.com/mkch/android-wifi-connecter and the following files in particular very helpful: