sPFWFDMid/src/main/java/it/polimi/spf/wfd/ServiceList.java
public WiFiP2pService getServiceByDevice(WifiP2pDevice device) {
        if (device == null) {
            return null;
        }

        WfdLog.d(TAG, "groupownerdevice passed to getServiceByDevice: " + device.deviceName + ", " + device.deviceAddress);

        WfdLog.d(TAG, "servicelist size: " + serviceList.size());

        for (WiFiP2pService element : serviceList) {
            WfdLog.d(TAG, "element in list: " + element.getDevice().deviceName + ", " + element.getDevice().deviceAddress);
            WfdLog.d(TAG, "element passed : " + device.deviceName + ", " + device.deviceAddress);

            if (element.getDevice().deviceAddress.equals(device.deviceAddress)) {
                WfdLog.d(TAG, "getServiceByDevice if satisfied : " + device.deviceAddress + ", " + element.getDevice().deviceAddress);
                return element;
            }
        }

        WfdLog.d(TAG, "servicelist size: " + serviceList.size());

        return null;
    }
public WiFiP2pService getServiceByDevice(WifiP2pDevice device) {
        if (device == null) {
            return null;
        }

        WfdLog.d(TAG, "groupownerdevice passed to getServiceByDevice: " + device.deviceName + ", " + device.deviceAddress);

        WfdLog.d(TAG, "servicelist size: " + serviceList.size());

        for (WiFiP2pService element : serviceList) {
            WfdLog.d(TAG, "element in list: " + element.getDevice().deviceName + ", " + element.getDevice().deviceAddress);
            WfdLog.d(TAG, "element passed : " + device.deviceName + ", " + device.deviceAddress);

            if (element.getDevice().deviceAddress.equals(device.deviceAddress)) {
                WfdLog.d(TAG, "getServiceByDevice if satisfied : " + device.deviceAddress + ", " + element.getDevice().deviceAddress);
                return element;
            }
        }

        WfdLog.d(TAG, "servicelist size: " + serviceList.size());

        return null;
    }
public WiFiP2pService getServiceByDevice ( WifiP2pDevice device ) { if ( device == null ) { return null ; } WfdLog . d ( TAG , "groupownerdevice passed to getServiceByDevice: " + device . deviceName + ", " + device . deviceAddress ) ; WfdLog . d ( TAG , "servicelist size: " + serviceList . size ( ) ) ; for ( WiFiP2pService element : serviceList ) { WfdLog . d ( TAG , "element in list: " + element . getDevice ( ) . deviceName + ", " + element . getDevice ( ) . deviceAddress ) ; WfdLog . d ( TAG , "element passed : " + device . deviceName + ", " + device . deviceAddress ) ; if ( element . getDevice ( ) . deviceAddress . equals ( device . deviceAddress ) ) { WfdLog . d ( TAG , "getServiceByDevice if satisfied : " + device . deviceAddress + ", " + element . getDevice ( ) . deviceAddress ) ; return element ; } } WfdLog . d ( TAG , "servicelist size: " + serviceList . size ( ) ) ; return null ; }
Method to get a service from the list, using only the device.
This method use only the deviceAddress, not the device name, because sometimes Android doesn't
get the name, but only the mac address.

@param device WifiP2pDevice that you want to use to search the service.
@return The WiFiP2pService associated to the device or null, if the device isn't in the list.
Method to get a service from the list using only the device . This method use only the deviceAddress not the device name because sometimes Android doesn t get the name but only the mac address .