Java 类android.net.wifi.WifiConfiguration.AuthAlgorithm 实例源码

项目:WiFiAPManager    文件:WifiApDialog.java   
public WifiConfiguration getConfig() {

        WifiConfiguration config = new WifiConfiguration();

        /**
         * TODO: SSID in WifiConfiguration for soft ap
         * is being stored as a raw string without quotes.
         * This is not the case on the client side. We need to
         * make things consistent and clean it up
         */
        config.SSID = mSsid.getText().toString();

        switch (mSecurityTypeIndex) {
            case OPEN_INDEX:
                config.allowedKeyManagement.set(Commons.KeyMgmt.NONE);
                return config;
            case WPA2_INDEX:
                config.allowedKeyManagement.set(Commons.KeyMgmt.WPA2_PSK);
                config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
                if (mPassword.length() != 0) {
                    config.preSharedKey = mPassword.getText().toString();
                }
                return config;
        }
        return null;
    }
项目:GOpenSource_AppKit_Android_AS    文件:WifiAutoConnectManager.java   
private WifiConfiguration createWifiInfo(String SSID, String Password,
        WifiCipherType Type) {
    WifiConfiguration config = new WifiConfiguration();
    config.allowedAuthAlgorithms.clear();
    config.allowedGroupCiphers.clear();
    config.allowedKeyManagement.clear();
    config.allowedPairwiseCiphers.clear();
    config.allowedProtocols.clear();
    config.SSID = "\"" + SSID + "\"";
    // config.SSID = SSID;
    // nopass
    if (Type == WifiCipherType.WIFICIPHER_NOPASS) {
        // config.wepKeys[0] = "";
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        // config.wepTxKeyIndex = 0;
    }
    // wep
    if (Type == WifiCipherType.WIFICIPHER_WEP) {
        if (!TextUtils.isEmpty(Password)) {
            if (isHexWepKey(Password)) {
                config.wepKeys[0] = Password;
            } else {
                config.wepKeys[0] = "\"" + Password + "\"";
            }
        }
        config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
        config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
        config.allowedKeyManagement.set(KeyMgmt.NONE);
        config.wepTxKeyIndex = 0;
    }
    // wpa
    if (Type == WifiCipherType.WIFICIPHER_WPA) {
        config.preSharedKey = "\"" + Password + "\"";
        config.hiddenSSID = true;
        config.allowedAuthAlgorithms
                .set(WifiConfiguration.AuthAlgorithm.OPEN);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        config.allowedPairwiseCiphers
                .set(WifiConfiguration.PairwiseCipher.TKIP);
        // 此处需要修改否则不能自动重联
        // config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        config.allowedPairwiseCiphers
                .set(WifiConfiguration.PairwiseCipher.CCMP);
        config.status = WifiConfiguration.Status.ENABLED;

    }
    return config;
}
项目:GizOpenSource_AppKit_Android    文件:WifiAutoConnectManager.java   
private WifiConfiguration createWifiInfo(String SSID, String Password,
        WifiCipherType Type) {
    WifiConfiguration config = new WifiConfiguration();
    config.allowedAuthAlgorithms.clear();
    config.allowedGroupCiphers.clear();
    config.allowedKeyManagement.clear();
    config.allowedPairwiseCiphers.clear();
    config.allowedProtocols.clear();
    config.SSID = "\"" + SSID + "\"";
    // config.SSID = SSID;
    // nopass
    if (Type == WifiCipherType.WIFICIPHER_NOPASS) {
        // config.wepKeys[0] = "";
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        // config.wepTxKeyIndex = 0;
    }
    // wep
    if (Type == WifiCipherType.WIFICIPHER_WEP) {
        if (!TextUtils.isEmpty(Password)) {
            if (isHexWepKey(Password)) {
                config.wepKeys[0] = Password;
            } else {
                config.wepKeys[0] = "\"" + Password + "\"";
            }
        }
        config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
        config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
        config.allowedKeyManagement.set(KeyMgmt.NONE);
        config.wepTxKeyIndex = 0;
    }
    // wpa
    if (Type == WifiCipherType.WIFICIPHER_WPA) {
        config.preSharedKey = "\"" + Password + "\"";
        config.hiddenSSID = true;
        config.allowedAuthAlgorithms
                .set(WifiConfiguration.AuthAlgorithm.OPEN);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        config.allowedPairwiseCiphers
                .set(WifiConfiguration.PairwiseCipher.TKIP);
        // 此处需要修改否则不能自动重联
        // config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        config.allowedPairwiseCiphers
                .set(WifiConfiguration.PairwiseCipher.CCMP);
        config.status = WifiConfiguration.Status.ENABLED;

    }
    return config;
}
项目:Gizwits-SmartBuld_Android    文件:WifiAutoConnectManager.java   
private WifiConfiguration createWifiInfo(String SSID, String Password, WifiCipherType Type) {
    WifiConfiguration config = new WifiConfiguration();
    config.allowedAuthAlgorithms.clear();
    config.allowedGroupCiphers.clear();
    config.allowedKeyManagement.clear();
    config.allowedPairwiseCiphers.clear();
    config.allowedProtocols.clear();
    config.SSID = "\"" + SSID + "\"";
    // nopass
    if (Type == WifiCipherType.WIFICIPHER_NOPASS) {
        // config.wepKeys[0] = "";
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        // config.wepTxKeyIndex = 0;
    }
    // wep
    if (Type == WifiCipherType.WIFICIPHER_WEP) {
        if (!TextUtils.isEmpty(Password)) {
            if (isHexWepKey(Password)) {
                config.wepKeys[0] = Password;
            } else {
                config.wepKeys[0] = "\"" + Password + "\"";
            }
        }
        config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
        config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
        config.allowedKeyManagement.set(KeyMgmt.NONE);
        config.wepTxKeyIndex = 0;
    }
    // wpa
    if (Type == WifiCipherType.WIFICIPHER_WPA) {
        config.preSharedKey = "\"" + Password + "\"";
        config.hiddenSSID = true;
        config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
        // 此处需要修改否则不能自动重联
        // config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        config.status = WifiConfiguration.Status.ENABLED;

    }
    return config;
}
项目:gokit-android    文件:WifiAutoConnectManager.java   
private WifiConfiguration createWifiInfo(String SSID, String Password,
        WifiCipherType Type) {
    WifiConfiguration config = new WifiConfiguration();
    config.allowedAuthAlgorithms.clear();
    config.allowedGroupCiphers.clear();
    config.allowedKeyManagement.clear();
    config.allowedPairwiseCiphers.clear();
    config.allowedProtocols.clear();
    config.SSID = "\"" + SSID + "\"";
    // config.SSID = SSID;
    // nopass
    if (Type == WifiCipherType.WIFICIPHER_NOPASS) {
        // config.wepKeys[0] = "";
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        // config.wepTxKeyIndex = 0;
    }
    // wep
    if (Type == WifiCipherType.WIFICIPHER_WEP) {
        if (!TextUtils.isEmpty(Password)) {
            if (isHexWepKey(Password)) {
                config.wepKeys[0] = Password;
            } else {
                config.wepKeys[0] = "\"" + Password + "\"";
            }
        }
        config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
        config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
        config.allowedKeyManagement.set(KeyMgmt.NONE);
        config.wepTxKeyIndex = 0;
    }
    // wpa
    if (Type == WifiCipherType.WIFICIPHER_WPA) {
        config.preSharedKey = "\"" + Password + "\"";
        config.hiddenSSID = true;
        config.allowedAuthAlgorithms
                .set(WifiConfiguration.AuthAlgorithm.OPEN);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        config.allowedPairwiseCiphers
                .set(WifiConfiguration.PairwiseCipher.TKIP);
        // 此处需要修改否则不能自动重联
        // config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        config.allowedPairwiseCiphers
                .set(WifiConfiguration.PairwiseCipher.CCMP);
        config.status = WifiConfiguration.Status.ENABLED;

    }
    return config;
}