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

WifiP2pDeviceList

public class WifiP2pDeviceList extends Object implements android.os.Parcelable
A class representing a Wi-Fi P2p device list. Note that the operations are not thread safe. {@see WifiP2pManager}

Fields Summary
private final HashMap
mDevices
public static final Creator
CREATOR
Implement the Parcelable interface
Constructors Summary
public WifiP2pDeviceList()


      
    
public WifiP2pDeviceList(WifiP2pDeviceList source)
copy constructor

        if (source != null) {
            for (WifiP2pDevice d : source.getDeviceList()) {
                mDevices.put(d.deviceAddress, new WifiP2pDevice(d));
            }
        }
    
public WifiP2pDeviceList(ArrayList devices)

hide

        for (WifiP2pDevice device : devices) {
            if (device.deviceAddress != null) {
                mDevices.put(device.deviceAddress, new WifiP2pDevice(device));
            }
        }
    
Methods Summary
public booleanclear()
Clear the list @hide

        if (mDevices.isEmpty()) return false;
        mDevices.clear();
        return true;
    
public intdescribeContents()
Implement the Parcelable interface

        return 0;
    
public android.net.wifi.p2p.WifiP2pDeviceget(java.lang.String deviceAddress)
Fetch a device from the list

param
deviceAddress is the address of the device
return
WifiP2pDevice device found, or null if none found

        validateDeviceAddress(deviceAddress);
        return mDevices.get(deviceAddress);
    
public java.util.CollectiongetDeviceList()
Get the list of devices

        return Collections.unmodifiableCollection(mDevices.values());
    
public booleanisGroupOwner(java.lang.String deviceAddress)

hide

        validateDeviceAddress(deviceAddress);
        WifiP2pDevice device = mDevices.get(deviceAddress);
        if (device == null) {
            throw new IllegalArgumentException("Device not found " + deviceAddress);
        }
        return device.isGroupOwner();
    
public booleanremove(android.net.wifi.p2p.WifiP2pDevice device)

hide

        validateDevice(device);
        return mDevices.remove(device.deviceAddress) != null;
    
public android.net.wifi.p2p.WifiP2pDeviceremove(java.lang.String deviceAddress)
Remove a device from the list

param
deviceAddress is the address of the device
return
WifiP2pDevice device removed, or null if none removed
hide

        validateDeviceAddress(deviceAddress);
        return mDevices.remove(deviceAddress);
    
public booleanremove(android.net.wifi.p2p.WifiP2pDeviceList list)
Returns true if any device the list was removed @hide

        boolean ret = false;
        for (WifiP2pDevice d : list.mDevices.values()) {
            if (remove(d)) ret = true;
        }
        return ret;
    
public java.lang.StringtoString()

        StringBuffer sbuf = new StringBuffer();
        for (WifiP2pDevice device : mDevices.values()) {
            sbuf.append("\n").append(device);
        }
        return sbuf.toString();
    
public voidupdate(android.net.wifi.p2p.WifiP2pDevice device)
Add/update a device to the list. If the device is not found, a new device entry is created. If the device is already found, the device details are updated

param
device to be updated
hide

        updateSupplicantDetails(device);
        mDevices.get(device.deviceAddress).status = device.status;
    
public voidupdateGroupCapability(java.lang.String deviceAddress, int groupCapab)

hide

        validateDeviceAddress(deviceAddress);
        WifiP2pDevice d = mDevices.get(deviceAddress);
        if (d != null) {
            d.groupCapability = groupCapab;
        }
    
public voidupdateStatus(java.lang.String deviceAddress, int status)

hide

        validateDeviceAddress(deviceAddress);
        WifiP2pDevice d = mDevices.get(deviceAddress);
        if (d != null) {
            d.status = status;
        }
    
public voidupdateSupplicantDetails(android.net.wifi.p2p.WifiP2pDevice device)
Only updates details fetched from the supplicant @hide

        validateDevice(device);
        WifiP2pDevice d = mDevices.get(device.deviceAddress);
        if (d != null) {
            d.deviceName = device.deviceName;
            d.primaryDeviceType = device.primaryDeviceType;
            d.secondaryDeviceType = device.secondaryDeviceType;
            d.wpsConfigMethodsSupported = device.wpsConfigMethodsSupported;
            d.deviceCapability = device.deviceCapability;
            d.groupCapability = device.groupCapability;
            d.wfdInfo = device.wfdInfo;
            return;
        }
        //Not found, add a new one
        mDevices.put(device.deviceAddress, device);
    
private voidvalidateDevice(android.net.wifi.p2p.WifiP2pDevice device)

        if (device == null) throw new IllegalArgumentException("Null device");
        if (TextUtils.isEmpty(device.deviceAddress)) {
            throw new IllegalArgumentException("Empty deviceAddress");
        }
    
private voidvalidateDeviceAddress(java.lang.String deviceAddress)

        if (TextUtils.isEmpty(deviceAddress)) {
            throw new IllegalArgumentException("Empty deviceAddress");
        }
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface

        dest.writeInt(mDevices.size());
        for(WifiP2pDevice device : mDevices.values()) {
            dest.writeParcelable(device, flags);
        }