你们中的 Android 专家是否知道有任何开源代码可以从给定的
WifiConfiguration
创建 ScanResult
?这会有帮助的。事实上,我捕获的 WifiConfiguration.java
Android 源代码的第 483 (/624) 行(2012 年 4 月中旬)是一个注释掉的构造函数,旨在做到这一点,有一个很大的 TODO 想知道它是否值得实现(参见下面的引用) 。我示意是,我可以听一下吗?
我看到的主要挑战(实际上是这个问题的首要挑战)是如何解释 ScanResult.configuration 字符串。
[WPA2-PSK-CCMP]
、[WPS]
等吗?来自
WifiConfiguration.java
(可能有编辑):
/**
* 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://github.com/mkch/android-wifi-connecter并且以下文件特别非常有用:
Android AOSP 中的此文件也很有帮助: WifiUtils