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

WifiInfo

public class WifiInfo extends Object implements android.os.Parcelable
Describes the state of any Wifi connection that is active or is in the process of being set up.

Fields Summary
private static final EnumMap
stateMap
This is the map described in the Javadoc comment above. The positions of the elements of the array must correspond to the ordinal values of DetailedState.
private SupplicantState
mSupplicantState
private String
mBSSID
private String
mSSID
private int
mNetworkId
private boolean
mHiddenSSID
private int
mRssi
Received Signal Strength Indicator
public static final String
LINK_SPEED_UNITS
Link speed in Mbps
private int
mLinkSpeed
private int
mIpAddress
private String
mMacAddress
public static final Creator
CREATOR
Implement the Parcelable interface {@hide}
Constructors Summary
WifiInfo()


     
        mSSID = null;
        mBSSID = null;
        mNetworkId = -1;
        mSupplicantState = SupplicantState.UNINITIALIZED;
        mRssi = -9999;
        mLinkSpeed = -1;
        mIpAddress = 0;
        mHiddenSSID = false;
    
Methods Summary
public intdescribeContents()
Implement the Parcelable interface {@hide}

        return 0;
    
public java.lang.StringgetBSSID()
Return the basic service set identifier (BSSID) of the current access point. The BSSID may be {@code null} if there is no network currently connected.

return
the BSSID, in the form of a six-byte MAC address: {@code XX:XX:XX:XX:XX:XX}

        return mBSSID;
    
public static android.net.NetworkInfo.DetailedStategetDetailedStateOf(SupplicantState suppState)
Map a supplicant state into a fine-grained network connectivity state.

param
suppState the supplicant state
return
the corresponding {@link DetailedState}

        return stateMap.get(suppState);
    
public booleangetHiddenSSID()

return
{@code true} if this network does not broadcast its SSID, so an SSID-specific probe request must be used for scans.

        return mHiddenSSID;
    
public intgetIpAddress()

        return mIpAddress;
    
public intgetLinkSpeed()
Returns the current link speed in {@link #LINK_SPEED_UNITS}.

return
the link speed.
see
#LINK_SPEED_UNITS

        return mLinkSpeed;
    
public java.lang.StringgetMacAddress()

        return mMacAddress;
    
public intgetNetworkId()
Each configured network has a unique small integer ID, used to identify the network when performing operations on the supplicant. This method returns the ID for the currently connected network.

return
the network ID, or -1 if there is no currently connected network

        return mNetworkId;
    
public intgetRssi()
Returns the received signal strength indicator of the current 802.11 network.

This is not normalized, but should be!

return
the RSSI, in the range ??? to ???

        return mRssi;
    
public java.lang.StringgetSSID()
Returns the service set identifier (SSID) of the current 802.11 network. If the SSID is an ASCII string, it will be returned surrounded by double quotation marks.Otherwise, it is returned as a string of hex digits. The SSID may be {@code null} if there is no network currently connected.

return
the SSID

        return mSSID;
    
public SupplicantStategetSupplicantState()
Return the detailed state of the supplicant's negotiation with an access point, in the form of a {@link SupplicantState SupplicantState} object.

return
the current {@link SupplicantState SupplicantState}

        return mSupplicantState;
    
voidsetBSSID(java.lang.String BSSID)

        mBSSID = BSSID;
    
public voidsetHiddenSSID(boolean hiddenSSID)
{@hide}

        mHiddenSSID = hiddenSSID;
    
voidsetIpAddress(int address)

        mIpAddress = address;
    
voidsetLinkSpeed(int linkSpeed)

        this.mLinkSpeed = linkSpeed;
    
voidsetMacAddress(java.lang.String macAddress)
Record the MAC address of the WLAN interface

param
macAddress the MAC address in {@code XX:XX:XX:XX:XX:XX} form

        this.mMacAddress = macAddress;
    
voidsetNetworkId(int id)

        mNetworkId = id;
    
voidsetRssi(int rssi)

        mRssi = rssi;
    
voidsetSSID(java.lang.String SSID)

        mSSID = SSID;
        // network is considered not hidden by default
        mHiddenSSID = false;
    
voidsetSupplicantState(SupplicantState state)

        mSupplicantState = state;
    
voidsetSupplicantState(java.lang.String stateName)
Set the SupplicantState from the string name of the state.

param
stateName the name of the state, as a String returned in an event sent by {@code wpa_supplicant}.

        mSupplicantState = valueOf(stateName);
    
public java.lang.StringtoString()

        StringBuffer sb = new StringBuffer();
        String none = "<none>";

        sb.append("SSID: ").append(mSSID == null ? none : mSSID).
            append(", BSSID: ").append(mBSSID == null ? none : mBSSID).
            append(", MAC: ").append(mMacAddress == null ? none : mMacAddress).
            append(", Supplicant state: ").
            append(mSupplicantState == null ? none : mSupplicantState).
            append(", RSSI: ").append(mRssi).
            append(", Link speed: ").append(mLinkSpeed).
            append(", Net ID: ").append(mNetworkId);

        return sb.toString();
    
static SupplicantStatevalueOf(java.lang.String stateName)

        if ("4WAY_HANDSHAKE".equalsIgnoreCase(stateName))
            return SupplicantState.FOUR_WAY_HANDSHAKE;
        else {
            try {
                return SupplicantState.valueOf(stateName.toUpperCase());
            } catch (IllegalArgumentException e) {
                return SupplicantState.INVALID;
            }
        }
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface {@hide}

        dest.writeInt(mNetworkId);
        dest.writeInt(mRssi);
        dest.writeInt(mLinkSpeed);
        dest.writeInt(mIpAddress);
        dest.writeString(getSSID());
        dest.writeString(mBSSID);
        dest.writeString(mMacAddress);
        mSupplicantState.writeToParcel(dest, flags);