Constructing a WifiConfiguration from a ScanResult or: Interpreting ScanResult's 'capabilities' String

拜拜、爱过 提交于 2019-12-05 16:37:17

问题


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.

  1. can I expect just a simple list of things like [WPA2-PSK-CCMP], [WPS], etc?
  2. are these strings enumerated somewhere in the docs or code base?
  3. are there device/manufacturer/AP-specific strings I should know about?

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
}   
*/

https://code.google.com/p/android/issues/detail?id=60523


回答1:


I found this project https://code.google.com/p/android-wifi-connecter/ and the following files in particular very helpful:

https://code.google.com/p/android-wifi-connecter/source/browse/src/com/farproc/wifi/connecter/Wifi.java https://code.google.com/p/android-wifi-connecter/source/browse/src/com/farproc/wifi/connecter/ConfigurationSecuritiesV8.java


EDIT - new links

https://github.com/mkch/android-wifi-connecter/blob/master/src/com/farproc/wifi/connecter/Wifi.java https://github.com/mkch/android-wifi-connecter/blob/master/src/com/farproc/wifi/connecter/ConfigurationSecuritiesV8.java



来源:https://stackoverflow.com/questions/10762533/constructing-a-wificonfiguration-from-a-scanresult-or-interpreting-scanresults

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!