public static String p2pConnect(WifiP2pConfig config, boolean joinExistingGroup) {
if (config == null) return null;
List<String> args = new ArrayList<String>();
- Wps wpsConfig = config.wpsConfig;
+ Wps wps = config.wps;
args.add(config.deviceAddress);
- switch (wpsConfig.setup) {
+ switch (wps.setup) {
case PBC:
args.add("pbc");
break;
args.add("display");
break;
case KEYPAD:
- args.add(wpsConfig.pin);
+ args.add(wps.pin);
args.add("keypad");
break;
case LABEL:
- args.add(wpsConfig.pin);
+ args.add(wps.pin);
args.add("label");
default:
break;
/**
* A class representing Wi-Fi Protected Setup
* @hide
+ *
+ * {@see WifiP2pConfig}
*/
public class Wps implements Parcelable {
- /* Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */
+ /** Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */
public enum Setup {
/* Push button configuration */
PBC,
/** @hide */
public String BSSID;
+ /** Passed with pin method configuration */
public String pin;
/** @hide */
/** @hide */
public LinkProperties linkProperties;
- /** @hide */
public Wps() {
setup = Setup.INVALID;
BSSID = null;
import android.os.Parcel;
/**
- * A class representing a Wi-Fi P2p configuration
+ * A class representing a Wi-Fi P2p configuration for setting up a connection
* @hide
+ *
+ * {@see WifiP2pManager}
*/
public class WifiP2pConfig implements Parcelable {
/**
- * Device address
+ * The device MAC address uniquely identifies a Wi-Fi p2p device
*/
public String deviceAddress;
/**
- * WPS configuration
+ * Wi-Fi Protected Setup information
*/
- public Wps wpsConfig;
+ public Wps wps;
/**
* This is an integer value between 0 and 15 where 0 indicates the least
public WifiP2pConfig() {
//set defaults
- wpsConfig = new Wps();
- wpsConfig.setup = Setup.PBC;
+ wps = new Wps();
+ wps.setup = Setup.PBC;
}
- /* P2P-GO-NEG-REQUEST 42:fc:89:a8:96:09 dev_passwd_id=4 */
+ /** P2P-GO-NEG-REQUEST 42:fc:89:a8:96:09 dev_passwd_id=4 {@hide}*/
public WifiP2pConfig(String supplicantEvent) throws IllegalArgumentException {
String[] tokens = supplicantEvent.split(" ");
}
deviceAddress = tokens[1];
- wpsConfig = new Wps();
+ wps = new Wps();
if (tokens.length > 2) {
String[] nameVal = tokens[2].split("=");
//As defined in wps/wps_defs.h
switch (devPasswdId) {
case 0x00:
- wpsConfig.setup = Setup.LABEL;
+ wps.setup = Setup.LABEL;
break;
case 0x01:
- wpsConfig.setup = Setup.KEYPAD;
+ wps.setup = Setup.KEYPAD;
break;
case 0x04:
- wpsConfig.setup = Setup.PBC;
+ wps.setup = Setup.PBC;
break;
case 0x05:
- wpsConfig.setup = Setup.DISPLAY;
+ wps.setup = Setup.DISPLAY;
break;
default:
- wpsConfig.setup = Setup.PBC;
+ wps.setup = Setup.PBC;
break;
}
}
}
+ /** @hide */
public String toString() {
StringBuffer sbuf = new StringBuffer();
sbuf.append("\n address: ").append(deviceAddress);
- sbuf.append("\n wps: ").append(wpsConfig);
+ sbuf.append("\n wps: ").append(wps);
sbuf.append("\n groupOwnerIntent: ").append(groupOwnerIntent);
sbuf.append("\n persist: ").append(persist.toString());
return sbuf.toString();
/** Implement the Parcelable interface {@hide} */
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(deviceAddress);
- dest.writeParcelable(wpsConfig, flags);
+ dest.writeParcelable(wps, flags);
dest.writeInt(groupOwnerIntent);
dest.writeString(persist.name());
}
public WifiP2pConfig createFromParcel(Parcel in) {
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = in.readString();
- config.wpsConfig = (Wps) in.readParcelable(null);
+ config.wps = (Wps) in.readParcelable(null);
config.groupOwnerIntent = in.readInt();
config.persist = Persist.valueOf(in.readString());
return config;
/**
* A class representing a Wi-Fi p2p device
* @hide
+ *
+ * {@see WifiP2pManager}
*/
public class WifiP2pDevice implements Parcelable {
private static final String TAG = "WifiP2pDevice";
+
/**
- * Device name
+ * The device name is a user friendly string to identify a Wi-Fi p2p device
*/
public String deviceName;
/**
- * Device MAC address
+ * The device MAC address uniquely identifies a Wi-Fi p2p device
*/
public String deviceAddress;
* P2P Interface Address and the group interface will be created with
* address as the local address in case of successfully completed
* negotiation.
+ * @hide
*/
public String interfaceAddress;
/**
- * Primary device type
+ * Primary device type identifies the type of device. For example, an application
+ * could filter the devices discovered to only display printers if the purpose is to
+ * enable a printing action from the user. See the Wi-Fi Direct technical specification
+ * for the full list of standard device types supported.
*/
public String primaryDeviceType;
/**
- * Secondary device type
+ * Secondary device type is an optional attribute that can be provided by a device in
+ * addition to the primary device type.
*/
public String secondaryDeviceType;
// These definitions match the ones in wpa_supplicant
/* WPS config methods supported */
- private static final int WPS_CONFIG_USBA = 0x0001;
- private static final int WPS_CONFIG_ETHERNET = 0x0002;
- private static final int WPS_CONFIG_LABEL = 0x0004;
private static final int WPS_CONFIG_DISPLAY = 0x0008;
- private static final int WPS_CONFIG_EXT_NFC_TOKEN = 0x0010;
- private static final int WPS_CONFIG_INT_NFC_TOKEN = 0x0020;
- private static final int WPS_CONFIG_NFC_INTERFACE = 0x0040;
private static final int WPS_CONFIG_PUSHBUTTON = 0x0080;
private static final int WPS_CONFIG_KEYPAD = 0x0100;
- private static final int WPS_CONFIG_VIRT_PUSHBUTTON = 0x0280;
- private static final int WPS_CONFIG_PHY_PUSHBUTTON = 0x0480;
- private static final int WPS_CONFIG_VIRT_DISPLAY = 0x2008;
- private static final int WPS_CONFIG_PHY_DISPLAY = 0x4008;
/* Device Capability bitmap */
private static final int DEVICE_CAPAB_SERVICE_DISCOVERY = 1;
/**
* WPS config methods supported
+ * @hide
*/
public int wpsConfigMethodsSupported;
/**
* Device capability
+ * @hide
*/
public int deviceCapability;
/**
* Group capability
+ * @hide
*/
public int groupCapability;
+ /** Device connection status */
public enum Status {
CONNECTED,
INVITED,
public Status status = Status.UNAVAILABLE;
- public WifiP2pDevice() {
+ WifiP2pDevice() {
}
/**
* group_capab=0x0
*
* Note: The events formats can be looked up in the wpa_supplicant code
+ * @hide
*/
public WifiP2pDevice(String string) throws IllegalArgumentException {
String[] tokens = string.split(" ");
}
}
+ /** Returns true if WPS push button configuration is supported */
+ public boolean wpsPbcSupported() {
+ return (wpsConfigMethodsSupported & WPS_CONFIG_PUSHBUTTON) != 0;
+ }
+
+ /** Returns true if WPS keypad configuration is supported */
+ public boolean wpsKeypadSupported() {
+ return (wpsConfigMethodsSupported & WPS_CONFIG_KEYPAD) != 0;
+ }
+
+ /** Returns true if WPS display configuration is supported */
+ public boolean wpsDisplaySupported() {
+ return (wpsConfigMethodsSupported & WPS_CONFIG_DISPLAY) != 0;
+ }
+
+ /** Returns true if the device is capable of service discovery */
+ public boolean isServiceDiscoveryCapable() {
+ return (deviceCapability & DEVICE_CAPAB_SERVICE_DISCOVERY) != 0;
+ }
+
+ /** Returns true if the device is a group owner */
public boolean isGroupOwner() {
return (groupCapability & GROUP_CAPAB_GROUP_OWNER) != 0;
}
@Override
+ /** @hide */
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof WifiP2pDevice)) return false;
return other.deviceAddress.equals(deviceAddress);
}
+ /** @hide */
public String toString() {
StringBuffer sbuf = new StringBuffer();
sbuf.append("Device: ").append(deviceName);
/**
* A class representing a Wi-Fi P2p device list
* @hide
+ *
+ * {@see WifiP2pManager}
*/
public class WifiP2pDeviceList implements Parcelable {
private Collection<WifiP2pDevice> mDevices;
- public WifiP2pDeviceList() {
+ WifiP2pDeviceList() {
mDevices = new ArrayList<WifiP2pDevice>();
}
- //copy constructor
+ /** copy constructor {@hide} */
public WifiP2pDeviceList(WifiP2pDeviceList source) {
if (source != null) {
mDevices = source.getDeviceList();
}
}
+ /** @hide */
public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices) {
mDevices = new ArrayList<WifiP2pDevice>();
for (WifiP2pDevice device : devices) {
}
}
+ /** @hide */
public boolean clear() {
if (mDevices.isEmpty()) return false;
mDevices.clear();
return true;
}
+ /** @hide */
public void update(WifiP2pDevice device) {
if (device == null) return;
for (WifiP2pDevice d : mDevices) {
mDevices.add(device);
}
+ /** @hide */
public boolean remove(WifiP2pDevice device) {
if (device == null) return false;
return mDevices.remove(device);
}
+ /** Get the list of devices */
public Collection<WifiP2pDevice> getDeviceList() {
return Collections.unmodifiableCollection(mDevices);
}
+ /** @hide */
public String toString() {
StringBuffer sbuf = new StringBuffer();
for (WifiP2pDevice device : mDevices) {
/**
* A class representing a Wi-Fi P2p group
* @hide
+ *
+ * {@see WifiP2pManager}
*/
public class WifiP2pGroup implements Parcelable {
import java.net.UnknownHostException;
/**
- * A class representing connection info on Wi-fi P2p
+ * A class representing connection information about a Wi-Fi p2p group
* @hide
+ *
+ * {@see WifiP2pManager}
*/
public class WifiP2pInfo implements Parcelable {
+ /** Indicates if a p2p group has been successfully formed */
public boolean groupFormed;
+ /** Indicates if the current device is the group owner */
public boolean isGroupOwner;
+ /** Group owner address */
public InetAddress groupOwnerAddress;
/** @hide */
* use {@link #requestConnectionInfo} to fetch the connection details. Connection information
* can be obtained with {@link #connectionInfoInResponse} on a {@link #RESPONSE_CONNECTION_INFO}
* message. The connection info {@link WifiP2pInfo} contains the address of the group owner
- * {@link WifiP2pInfo#groupOwnerAddress} and a flag {@link #WifiP2pInfo#isGroupOwner} to indicate
+ * {@link WifiP2pInfo#groupOwnerAddress} and a flag {@link WifiP2pInfo#isGroupOwner} to indicate
* if the current device is a p2p group owner. A p2p client can thus communicate with
* the p2p group owner through a socket connection.
*
* {@see WifiP2pGroup}
* {@see WifiP2pDevice}
* {@see WifiP2pDeviceList}
+ * {@see android.net.wifi.Wps}
* @hide
*/
public class WifiP2pManager {
private void notifyP2pGoNegotationRequest(WifiP2pConfig config) {
Resources r = Resources.getSystem();
- Wps wpsConfig = config.wpsConfig;
+ Wps wps = config.wps;
final View textEntryView = LayoutInflater.from(mContext)
.inflate(R.layout.wifi_p2p_go_negotiation_request_alert, null);
final EditText pin = (EditText) textEntryView .findViewById(R.id.wifi_p2p_wps_pin);
if (DBG) logd(getName() + " connect " + pin.getText());
if (pin.getVisibility() == View.GONE) {
- mSavedGoNegotiationConfig.wpsConfig.setup = Setup.PBC;
+ mSavedGoNegotiationConfig.wps.setup = Setup.PBC;
} else {
- mSavedGoNegotiationConfig.wpsConfig.setup = Setup.KEYPAD;
- mSavedGoNegotiationConfig.wpsConfig.pin = pin.getText().toString();
+ mSavedGoNegotiationConfig.wps.setup = Setup.KEYPAD;
+ mSavedGoNegotiationConfig.wps.pin = pin.getText().toString();
}
sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
mSavedGoNegotiationConfig = null;
})
.create();
- if (wpsConfig.setup == Setup.PBC) {
+ if (wps.setup == Setup.PBC) {
pin.setVisibility(View.GONE);
dialog.setMessage(r.getString(R.string.wifi_p2p_pbc_go_negotiation_request_message,
config.deviceAddress));