通过NFC WiFi类型参数的Android设备所有者
“WiFi安全类型”字段的可能值是什么? 文档中没有列出可能的值。 我想要一份如下清单:通过NFC WiFi类型参数的Android设备所有者,android,wifi,nfc,enterprise,Android,Wifi,Nfc,Enterprise,“WiFi安全类型”字段的可能值是什么? 文档中没有列出可能的值。 我想要一份如下清单: WPA = "wpa" WPA2 = "wpa2" WPA2-personal = "wpa2personal" WPA2-enterprise = "wpa2enterprise" 等等 我不愿意尝试一些事情,比如“暴力强迫”什么有效,什么无效,因为每次你尝试,你都必须擦干净,重新开始。浪费至少15分钟。从Android 5.0.0_r1到5.1.0_r1,可接受的字段为“无”、“WPA”和“WEP”
WPA = "wpa"
WPA2 = "wpa2"
WPA2-personal = "wpa2personal"
WPA2-enterprise = "wpa2enterprise"
等等
我不愿意尝试一些事情,比如“暴力强迫”什么有效,什么无效,因为每次你尝试,你都必须擦干净,重新开始。浪费至少15分钟。从Android 5.0.0_r1到5.1.0_r1,可接受的字段为“无”、“WPA”和“WEP”。看起来null或空值将解析为“NONE”,但我尚未确认 这些字段直接映射到ManagedProvisioning项目(AOSP)中的WifiConfig类 注意:安全类型直接在此类中定义,而不是使用WifiConfiguration类中的常量
enum SecurityType {
NONE,
WPA,
WEP;
}
这是WifiConfig函数(AOSP)的一个片段,显示了如何使用安全类型:
/**
* Adds a new WiFi network.
*/
public int addNetwork(String ssid, boolean hidden, String type, String password,
String proxyHost, int proxyPort, String proxyBypassHosts, String pacUrl) {
if (!mWifiManager.isWifiEnabled()) {
mWifiManager.setWifiEnabled(true);
}
WifiConfiguration wifiConf = new WifiConfiguration();
SecurityType securityType;
if (type == null || TextUtils.isEmpty(type)) {
securityType = SecurityType.NONE;
} else {
securityType = Enum.valueOf(SecurityType.class, type.toUpperCase());
}
// If we have a password, and no security type, assume WPA.
// TODO: Remove this when the programmer supports it.
if (securityType.equals(SecurityType.NONE) && !TextUtils.isEmpty(password)) {
securityType = SecurityType.WPA;
}
wifiConf.SSID = ssid;
wifiConf.status = WifiConfiguration.Status.ENABLED;
wifiConf.hiddenSSID = hidden;
switch (securityType) {
case NONE:
wifiConf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wifiConf.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
break;
case WPA:
updateForWPAConfiguration(wifiConf, password);
break;
case WEP:
updateForWEPConfiguration(wifiConf, password);
break;
}
updateForProxy(wifiConf, proxyHost, proxyPort, proxyBypassHosts, pacUrl);
int netId = mWifiManager.addNetwork(wifiConf);
if (netId != -1) {
// Setting disableOthers to 'true' should trigger a connection attempt.
mWifiManager.enableNetwork(netId, true);
mWifiManager.saveConfiguration();
}
return netId;
}
如果我们需要一个企业网络的凭据,似乎我们就不走运了。这让我有点困惑,因为设备所有者功能是为MDM设计的;有时需要连接到企业网络 第5.1.1条也没有变化。