【问题标题】:Android Device Owner via NFC WiFi-type parameterAndroid 设备所有者通过 NFC WiFi 类型参数
【发布时间】:2015-02-26 08:08:53
【问题描述】:

“WiFi 安全类型”字段的可能值是什么? 该文档没有列出可能的值。 https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#EXTRA_PROVISIONING_WIFI_SECURITY_TYPE

我想要一个类似的列表:

WPA = "wpa"
WPA2 = "wpa2"
WPA2-personal = "wpa2personal"
WPA2-enterprise = "wpa2enterprise"

等等

我不愿意尝试一些事情,比如“暴力破解”哪些有效,哪些无效,因为每次尝试时,您都必须擦除并重新开始。浪费了至少 15 分钟。

【问题讨论】:

    标签: android wifi nfc enterprise


    【解决方案1】:

    从 Android 5.0.0_r1-5.1.0_r1 开始,可接受的字段为“NONE”、“WPA”和“WEP”。似乎 null 或空值将解析为“NONE”,但我尚未确认。

    这些字段直接映射到 ManagedProvisioning 项目 (AOSP) 中的 WifiConfig 类。

    https://android.googlesource.com/platform/packages/apps/ManagedProvisioning/+/android-5.0.0_r7/src/com/android/managedprovisioning/WifiConfig.java

    注意:安全类型直接在此类中定义,而不是使用 WifiConfiguration 类中的常量。

    enum SecurityType {
        NONE,
        WPA,
        WEP;
    }
    

    这是 WifiConfig 函数 (AOSP) 的 sn-p,显示了如何使用安全类型:

    /**
     * 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 设计的。有时需要连接到企业网络!

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-13
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    相关资源
    最近更新 更多