FileDocCategorySizeDatePackage
WifiConfiguration.javaAPI DocAndroid 1.5 API15175Wed May 06 22:42:04 BST 2009android.net.wifi

WifiConfiguration

public class WifiConfiguration extends Object implements android.os.Parcelable
A class representing a configured Wi-Fi network, including the security configuration. Android will not necessarily support all of these security schemes initially.

Fields Summary
public static final String
ssidVarName
{@hide}
public static final String
bssidVarName
{@hide}
public static final String
pskVarName
{@hide}
public static final String[]
wepKeyVarNames
{@hide}
public static final String
wepTxKeyIdxVarName
{@hide}
public static final String
priorityVarName
{@hide}
public static final String
hiddenSSIDVarName
{@hide}
public int
networkId
The ID number that the supplicant uses to identify this network configuration entry. This must be passed as an argument to most calls into the supplicant.
public int
status
The current status of this network configuration entry.
public String
SSID
The network's SSID. Can either be an ASCII string, which must be enclosed in double quotation marks (e.g., {@code "MyNetwork"}, or a string of hex digits,which are not enclosed in quotes (e.g., {@code 01a243f405}).
public String
BSSID
When set, this network configuration entry should only be used when associating with the AP having the specified BSSID. The value is a string in the format of an Ethernet MAC address, e.g., XX:XX:XX:XX:XX:XX where each X is a hex digit.
public String
preSharedKey
Pre-shared key for use with WPA-PSK.

When the value of this key is read, the actual key is not returned, just a "*" if the key has a value, or the null string otherwise.

public String[]
wepKeys
Up to four WEP keys. Either an ASCII string enclosed in double quotation marks (e.g., {@code "abcdef"} or a string of hex digits (e.g., {@code 0102030405}).

When the value of one of these keys is read, the actual key is not returned, just a "*" if the key has a value, or the null string otherwise.

public int
wepTxKeyIndex
Default WEP key index, ranging from 0 to 3.
public int
priority
Priority determines the preference given to a network by {@code wpa_supplicant} when choosing an access point with which to associate.
public boolean
hiddenSSID
This is a network that does not broadcast its SSID, so an SSID-specific probe request must be used for scans.
public BitSet
allowedKeyManagement
The set of key management protocols supported by this configuration. See {@link KeyMgmt} for descriptions of the values. Defaults to WPA-PSK WPA-EAP.
public BitSet
allowedProtocols
The set of security protocols supported by this configuration. See {@link Protocol} for descriptions of the values. Defaults to WPA RSN.
public BitSet
allowedAuthAlgorithms
The set of authentication protocols supported by this configuration. See {@link AuthAlgorithm} for descriptions of the values. Defaults to automatic selection.
public BitSet
allowedPairwiseCiphers
The set of pairwise ciphers for WPA supported by this configuration. See {@link PairwiseCipher} for descriptions of the values. Defaults to CCMP TKIP.
public BitSet
allowedGroupCiphers
The set of group ciphers supported by this configuration. See {@link GroupCipher} for descriptions of the values. Defaults to CCMP TKIP WEP104 WEP40.
public static final Creator
CREATOR
Implement the Parcelable interface {@hide}
Constructors Summary
public WifiConfiguration()


      
        networkId = -1;
        SSID = null;
        BSSID = null;
        priority = 0;
        hiddenSSID = false;
        allowedKeyManagement = new BitSet();
        allowedProtocols = new BitSet();
        allowedAuthAlgorithms = new BitSet();
        allowedPairwiseCiphers = new BitSet();
        allowedGroupCiphers = new BitSet();
        wepKeys = new String[4];
        for (int i = 0; i < wepKeys.length; i++)
            wepKeys[i] = null;
    
Methods Summary
public intdescribeContents()
Implement the Parcelable interface {@hide}

        return 0;
    
private static java.util.BitSetreadBitSet(android.os.Parcel src)
Construct a WifiConfiguration from a scanned network

param
scannedAP the scan result used to construct the config entry TODO: figure out whether this is a useful way to construct a new entry. public WifiConfiguration(ScanResult scannedAP) { networkId = -1; SSID = scannedAP.SSID; BSSID = scannedAP.BSSID; }

        int cardinality = src.readInt();

        BitSet set = new BitSet();
        for (int i = 0; i < cardinality; i++)
            set.set(src.readInt());

        return set;
    
public java.lang.StringtoString()

        StringBuffer sbuf = new StringBuffer();
        if (this.status == WifiConfiguration.Status.CURRENT) {
            sbuf.append("* ");
        } else if (this.status == WifiConfiguration.Status.DISABLED) {
            sbuf.append("- ");
        }
        sbuf.append("ID: ").append(this.networkId).append(" SSID: ").append(this.SSID).
                append(" BSSID: ").append(this.BSSID).append(" PRIO: ").append(this.priority).
                append('\n");
        sbuf.append(" KeyMgmt:");
        for (int k = 0; k < this.allowedKeyManagement.size(); k++) {
            if (this.allowedKeyManagement.get(k)) {
                sbuf.append(" ");
                if (k < KeyMgmt.strings.length) {
                    sbuf.append(KeyMgmt.strings[k]);
                } else {
                    sbuf.append("??");
                }
            }
        }
        sbuf.append(" Protocols:");
        for (int p = 0; p < this.allowedProtocols.size(); p++) {
            if (this.allowedProtocols.get(p)) {
                sbuf.append(" ");
                if (p < Protocol.strings.length) {
                    sbuf.append(Protocol.strings[p]);
                } else {
                    sbuf.append("??");
                }
            }
        }
        sbuf.append('\n");
        sbuf.append(" AuthAlgorithms:");
        for (int a = 0; a < this.allowedAuthAlgorithms.size(); a++) {
            if (this.allowedAuthAlgorithms.get(a)) {
                sbuf.append(" ");
                if (a < AuthAlgorithm.strings.length) {
                    sbuf.append(AuthAlgorithm.strings[a]);
                } else {
                    sbuf.append("??");
                }
            }
        }
        sbuf.append('\n");
        sbuf.append(" PairwiseCiphers:");
        for (int pc = 0; pc < this.allowedPairwiseCiphers.size(); pc++) {
            if (this.allowedPairwiseCiphers.get(pc)) {
                sbuf.append(" ");
                if (pc < PairwiseCipher.strings.length) {
                    sbuf.append(PairwiseCipher.strings[pc]);
                } else {
                    sbuf.append("??");
                }
            }
        }
        sbuf.append('\n");
        sbuf.append(" GroupCiphers:");
        for (int gc = 0; gc < this.allowedGroupCiphers.size(); gc++) {
            if (this.allowedGroupCiphers.get(gc)) {
                sbuf.append(" ");
                if (gc < GroupCipher.strings.length) {
                    sbuf.append(GroupCipher.strings[gc]);
                } else {
                    sbuf.append("??");
                }
            }
        }
        sbuf.append('\n");
        if (this.preSharedKey != null) {
            sbuf.append(" PSK: ").append('*");
        }
        return sbuf.toString();
    
private static voidwriteBitSet(android.os.Parcel dest, java.util.BitSet set)

        int nextSetBit = -1;

        dest.writeInt(set.cardinality());

        while ((nextSetBit = set.nextSetBit(nextSetBit + 1)) != -1)
            dest.writeInt(nextSetBit);
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface {@hide}

        dest.writeInt(networkId);
        dest.writeInt(status);
        dest.writeString(SSID);
        dest.writeString(BSSID);
        dest.writeString(preSharedKey);
        for (String wepKey : wepKeys)
            dest.writeString(wepKey);
        dest.writeInt(wepTxKeyIndex);
        dest.writeInt(priority);
        dest.writeInt(hiddenSSID ? 1 : 0);

        writeBitSet(dest, allowedKeyManagement);
        writeBitSet(dest, allowedProtocols);
        writeBitSet(dest, allowedAuthAlgorithms);
        writeBitSet(dest, allowedPairwiseCiphers);
        writeBitSet(dest, allowedGroupCiphers);