[英]Android Device Owner via NFC WiFi-type parameter
What are the possible values for the field 'WiFi Security Type' ? “ WiFi安全类型”字段的可能值是什么? The documentation does not list possible values. 该文档未列出可能的值。 https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#EXTRA_PROVISIONING_WIFI_SECURITY_TYPE https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#EXTRA_PROVISIONING_WIFI_SECURITY_TYPE
I would like to have a list like: 我想要一个类似的清单:
WPA = "wpa"
WPA2 = "wpa2"
WPA2-personal = "wpa2personal"
WPA2-enterprise = "wpa2enterprise"
etc. 等等
I'm not willing to try things out, like 'brute-forcing' what works and what does not work, as every time you try, you'll have to wipe and start over. 我不愿意尝试一些事情,例如“强行使用”,什么有效,什么无效,因为每次尝试时,您都必须擦拭并重新开始。 Wasting at least 15 minutes. 浪费至少15分钟。
As of Android 5.0.0_r1-5.1.0_r1, the acceptable fields are "NONE", "WPA", and "WEP". 从Android 5.0.0_r1-5.1.0_r1开始,可接受的字段为“ NONE”,“ WPA”和“ WEP”。 It appears that a null or empty value will resolve to "NONE" but I haven't confirmed. 看来空值或空值将解析为“ NONE”,但我尚未确认。
The fields are directly mapped to a WifiConfig class in the ManagedProvisioning project (AOSP). 这些字段直接映射到ManagedProvisioning项目(AOSP)中的WifiConfig类。
https://android.googlesource.com/platform/packages/apps/ManagedProvisioning/+/android-5.0.0_r7/src/com/android/managedprovisioning/WifiConfig.java https://android.googlesource.com/platform/packages/apps/ManagedProvisioning/+/android-5.0.0_r7/src/com/android/managedprovisioning/WifiConfig.java
Note: The security type is defined directly in this class, instead of using constants from the WifiConfiguration class. 注意:安全类型直接在此类中定义,而不是使用WifiConfiguration类中的常量。
enum SecurityType {
NONE,
WPA,
WEP;
}
And this is a snippet of the WifiConfig function (AOSP) showing how the security type is used: 这是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;
}
Seems we're out of luck if we require credentials for an enterprise network. 如果我们需要企业网络的凭据,似乎我们不走运。 It's a bit baffling to me since the device owner feature is meant for MDM; 对我来说有点莫名其妙,因为设备所有者功能适用于MDM。 connecting to enterprise networks is sometimes a requirement! 有时需要连接到企业网络!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.