use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by crdroidandroid.
the class WifiP2pDeviceList method updateSupplicantDetails.
/** Only updates details fetched from the supplicant @hide */
public void updateSupplicantDetails(WifiP2pDevice device) {
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);
}
use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by crdroidandroid.
the class WifiP2pServiceResponse method newInstance.
/**
* Create the list of WifiP2pServiceResponse instance from supplicant event.
*
* <pre>The format is as follows.
* P2P-SERV-DISC-RESP <address> <update indicator> <response data>
* e.g) P2P-SERV-DISC-RESP 02:03:7f:11:62:da 1 0300000101
*
* @param supplicantEvent wpa_supplicant event string.
* @return if parse failed, return null
* @hide
*/
public static List<WifiP2pServiceResponse> newInstance(String supplicantEvent) {
List<WifiP2pServiceResponse> respList = new ArrayList<WifiP2pServiceResponse>();
String[] args = supplicantEvent.split(" ");
if (args.length != 4) {
return null;
}
WifiP2pDevice dev = new WifiP2pDevice();
String srcAddr = args[1];
dev.deviceAddress = srcAddr;
//String updateIndicator = args[2];//not used.
byte[] bin = hexStr2Bin(args[3]);
if (bin == null) {
return null;
}
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bin));
try {
while (dis.available() > 0) {
/*
* Service discovery header is as follows.
* ______________________________________________________________
* | Length(2byte) | Type(1byte) | TransId(1byte)}|
* ______________________________________________________________
* | status(1byte) | vendor specific(variable) |
*/
// The length equals to 3 plus the number of octets in the vendor
// specific content field. And this is little endian.
int length = (dis.readUnsignedByte() + (dis.readUnsignedByte() << 8)) - 3;
int type = dis.readUnsignedByte();
int transId = dis.readUnsignedByte();
int status = dis.readUnsignedByte();
if (length < 0) {
return null;
}
if (length == 0) {
if (status == Status.SUCCESS) {
respList.add(new WifiP2pServiceResponse(type, status, transId, dev, null));
}
continue;
}
if (length > MAX_BUF_SIZE) {
dis.skip(length);
continue;
}
byte[] data = new byte[length];
dis.readFully(data);
WifiP2pServiceResponse resp;
if (type == WifiP2pServiceInfo.SERVICE_TYPE_BONJOUR) {
resp = WifiP2pDnsSdServiceResponse.newInstance(status, transId, dev, data);
} else if (type == WifiP2pServiceInfo.SERVICE_TYPE_UPNP) {
resp = WifiP2pUpnpServiceResponse.newInstance(status, transId, dev, data);
} else {
resp = new WifiP2pServiceResponse(type, status, transId, dev, data);
}
if (resp != null && resp.getStatus() == Status.SUCCESS) {
respList.add(resp);
}
}
return respList;
} catch (IOException e) {
e.printStackTrace();
}
if (respList.size() > 0) {
return respList;
}
return null;
}
use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by crdroidandroid.
the class WifiDisplayController method handleScanResults.
private void handleScanResults() {
final int count = mAvailableWifiDisplayPeers.size();
final WifiDisplay[] displays = WifiDisplay.CREATOR.newArray(count);
for (int i = 0; i < count; i++) {
WifiP2pDevice device = mAvailableWifiDisplayPeers.get(i);
displays[i] = createWifiDisplay(device);
updateDesiredDevice(device);
}
mHandler.post(new Runnable() {
@Override
public void run() {
mListener.onScanResults(displays);
}
});
}
use of android.net.wifi.p2p.WifiP2pDevice in project android_packages_apps_Settings by LineageOS.
the class P2pThisDevicePreferenceControllerTest method updateDeviceName_hasName_shouldUseName.
@Test
public void updateDeviceName_hasName_shouldUseName() {
WifiP2pDevice device = new WifiP2pDevice();
device.deviceAddress = "address";
device.deviceName = "name";
mController.displayPreference(mPreferenceScreen);
mController.updateDeviceName(device);
assertThat(mPreference.getTitle()).isEqualTo(device.deviceName);
}
use of android.net.wifi.p2p.WifiP2pDevice in project android_packages_apps_Settings by LineageOS.
the class P2pThisDevicePreferenceControllerTest method updateDeviceName_emptyName_shouldUseIpAddress.
@Test
public void updateDeviceName_emptyName_shouldUseIpAddress() {
WifiP2pDevice device = new WifiP2pDevice();
device.deviceAddress = "address";
mController.displayPreference(mPreferenceScreen);
mController.updateDeviceName(device);
assertThat(mPreference.getTitle()).isEqualTo(device.deviceAddress);
}
Aggregations