FileDocCategorySizeDatePackage
WifiP2pConfig.javaAPI DocAndroid 5.1 API4950Thu Mar 12 22:22:44 GMT 2015android.net.wifi.p2p

WifiP2pConfig

public class WifiP2pConfig extends Object implements android.os.Parcelable
A class representing a Wi-Fi P2p configuration for setting up a connection {@see WifiP2pManager}

Fields Summary
public String
deviceAddress
The device MAC address uniquely identifies a Wi-Fi p2p device
public android.net.wifi.WpsInfo
wps
Wi-Fi Protected Setup information
public static final int
MAX_GROUP_OWNER_INTENT
public static final int
MIN_GROUP_OWNER_INTENT
public int
groupOwnerIntent
This is an integer value between 0 and 15 where 0 indicates the least inclination to be a group owner and 15 indicates the highest inclination to be a group owner. A value of -1 indicates the system can choose an appropriate value.
public int
netId
public static final Creator
CREATOR
Implement the Parcelable interface
Constructors Summary
public WifiP2pConfig()


      
        //set defaults
        wps = new WpsInfo();
        wps.setup = WpsInfo.PBC;
    
public WifiP2pConfig(String supplicantEvent)
P2P-GO-NEG-REQUEST 42:fc:89:a8:96:09 dev_passwd_id=4 {@hide}

        String[] tokens = supplicantEvent.split(" ");

        if (tokens.length < 2 || !tokens[0].equals("P2P-GO-NEG-REQUEST")) {
            throw new IllegalArgumentException("Malformed supplicant event");
        }

        deviceAddress = tokens[1];
        wps = new WpsInfo();

        if (tokens.length > 2) {
            String[] nameVal = tokens[2].split("=");
            int devPasswdId;
            try {
                devPasswdId = Integer.parseInt(nameVal[1]);
            } catch (NumberFormatException e) {
                devPasswdId = 0;
            }
            //Based on definitions in wps/wps_defs.h
            switch (devPasswdId) {
                //DEV_PW_USER_SPECIFIED = 0x0001,
                case 0x01:
                    wps.setup = WpsInfo.DISPLAY;
                    break;
                //DEV_PW_PUSHBUTTON = 0x0004,
                case 0x04:
                    wps.setup = WpsInfo.PBC;
                    break;
                //DEV_PW_REGISTRAR_SPECIFIED = 0x0005
                case 0x05:
                    wps.setup = WpsInfo.KEYPAD;
                    break;
                default:
                    wps.setup = WpsInfo.PBC;
                    break;
            }
        }
    
public WifiP2pConfig(WifiP2pConfig source)
copy constructor

        if (source != null) {
            deviceAddress = source.deviceAddress;
            wps = new WpsInfo(source.wps);
            groupOwnerIntent = source.groupOwnerIntent;
            netId = source.netId;
        }
    
Methods Summary
public intdescribeContents()
Implement the Parcelable interface

        return 0;
    
public voidinvalidate()

hide

        deviceAddress = "";
    
public java.lang.StringtoString()

        StringBuffer sbuf = new StringBuffer();
        sbuf.append("\n address: ").append(deviceAddress);
        sbuf.append("\n wps: ").append(wps);
        sbuf.append("\n groupOwnerIntent: ").append(groupOwnerIntent);
        sbuf.append("\n persist: ").append(netId);
        return sbuf.toString();
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface

        dest.writeString(deviceAddress);
        dest.writeParcelable(wps, flags);
        dest.writeInt(groupOwnerIntent);
        dest.writeInt(netId);