Example usage for android.net.wifi WifiConfiguration toString

List of usage examples for android.net.wifi WifiConfiguration toString

Introduction

In this page you can find the example usage for android.net.wifi WifiConfiguration toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.wahtod.wififixer.ui.ConnectFragment.java

private WifiConfiguration getKeyAppropriateConfig(String password) {
    WifiConfiguration wf = new WifiConfiguration();
    if (wf.toString().contains(BUGGED)) {
        /*/*from w  w  w  . j  a  v a2 s .  c o m*/
         * Add hidden fields on bugged Android 3.1+ configs
        */
        wf = addHiddenFields(wf);
    }
    wf.SSID = StringUtil.addQuotes(mNetwork.SSID);
    if (mNetwork.capabilities.length() == 0) {
        wf.BSSID = mNetwork.BSSID;
        wf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        wf.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
        return wf;
    }

    wf.status = WifiConfiguration.Status.ENABLED;
    wf.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
    if (mNetwork.capabilities.contains(WPA)) {
        wf.preSharedKey = StringUtil.addQuotes(password);
        wf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        wf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        wf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        wf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
        wf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
    } else if (mNetwork.capabilities.contains(WEP)) {
        wf.wepKeys[0] = StringUtil.addQuotes(password);
        wf.wepTxKeyIndex = 0;
        wf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        wf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
        wf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
    }

    return wf;
}