Skip to content

Commit ee58d3c

Browse files
committed
fix: exclude the AppleTV devices from the device discovery
1 parent aef3881 commit ee58d3c

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

IOSDeviceLib/IOSDeviceLib.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ void get_device_properties(std::string device_identifier, json &result)
239239
result["productType"] = get_device_property_value(device_identifier, "ProductType");
240240
result["deviceName"] = get_device_property_value(device_identifier, "DeviceName");
241241
result["productVersion"] = get_device_property_value(device_identifier, kProductVersion);
242-
result["deviceColor"] = get_device_property_value(device_identifier, "DeviceColor");
242+
result["deviceColor"] = get_device_property_value(device_identifier, "DeviceColor");
243+
result["deviceClass"] = get_device_property_value(device_identifier, "DeviceClass");
243244
// available values:
244245
// "BluetoothAddress","BoardId","CPUArchitecture","ChipID","DeviceClass",
245246
// "DeviceColor","DeviceName","FirmwareVersion","HardwareModel",
@@ -261,13 +262,13 @@ void update_device_result(std::string device_identifier, json &result)
261262

262263
void on_device_found(const DevicePointer* device_ptr, std::string device_identifier, json &result)
263264
{
264-
/*
265-
Interface type can be one of the followings:
266-
-1 - invalid interface type
267-
0 - unknown interface type
268-
1 - usb interface type
269-
2 - wifi interface type
270-
*/
265+
/*
266+
Interface type can be one of the followings:
267+
-1 - invalid interface type
268+
0 - unknown interface type
269+
1 - usb interface type
270+
2 - wifi interface type
271+
*/
271272
int interface_type = AMDeviceGetInterfaceType(device_ptr->device_info);
272273
if (interface_type == kUSBInterfaceType || interface_type == kWIFIInterfaceType) {
273274
if (devices.count(device_identifier)) {
@@ -286,13 +287,17 @@ void on_device_found(const DevicePointer* device_ptr, std::string device_identif
286287
}
287288

288289
update_device_result(device_identifier, result);
290+
if (result["deviceClass"] == "AppleTV") {
291+
// We do not support AppleTV devices
292+
result = nullptr;
293+
}
289294
}
290295
}
291296

292297
void device_notification_callback(const DevicePointer* device_ptr)
293298
{
294299
std::string device_identifier = get_cstring_from_cfstring(AMDeviceCopyDeviceIdentifier(device_ptr->device_info));
295-
json result;
300+
json result = nullptr;
296301
result[kDeviceId] = device_identifier;
297302
switch (device_ptr->msg)
298303
{
@@ -339,7 +344,9 @@ void device_notification_callback(const DevicePointer* device_ptr)
339344
}
340345
}
341346

342-
print(result);
347+
if (result != nullptr) {
348+
print(result);
349+
}
343350
}
344351

345352
#ifdef _WIN32

0 commit comments

Comments
 (0)