Skip to content

Commit 4f819b7

Browse files
committed
List only devices connected by usb
Current behaviour: Sometimes devices connected by wifi are reported as found. This leads to some unpredictable behaviour when livesync is executed. New behaviour: Only devices connected by usb are reported as found. NativeScript/nativescript-cli#1398
1 parent 9986034 commit 4f819b7

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

IOSDeviceLib/IOSDeviceLib.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ inline bool has_complete_status(std::map<std::string, boost::any>& dict)
245245
return boost::any_cast<std::string>(dict[kStatusKey]) == kComplete;
246246
}
247247

248+
void on_device_found(const DevicePointer* device_ptr, std::string device_identifier, std::string eventString, json &result)
249+
{
250+
/*
251+
Interface type can be one of the followings:
252+
-1 - invalid interface type
253+
0 - unknown interface type
254+
1 - usb interface type
255+
2 - wifi interface type
256+
*/
257+
int interface_type = AMDeviceGetInterfaceType(device_ptr->device_info);
258+
if (interface_type == kUSBInterfaceType) {
259+
devices[device_identifier] = { device_ptr->device_info, nullptr };
260+
result[kEventString] = eventString;
261+
get_device_properties(device_identifier, result);
262+
}
263+
}
264+
248265
void device_notification_callback(const DevicePointer* device_ptr)
249266
{
250267
std::string device_identifier = get_cstring_from_cfstring(AMDeviceCopyDeviceIdentifier(device_ptr->device_info));
@@ -254,9 +271,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
254271
{
255272
case kADNCIMessageConnected:
256273
{
257-
devices[device_identifier] = { device_ptr->device_info, nullptr };
258-
result[kEventString] = kDeviceFound;
259-
get_device_properties(device_identifier, result);
274+
on_device_found(device_ptr, device_identifier, kDeviceFound, result);
260275
break;
261276
}
262277
case kADNCIMessageDisconnected:
@@ -280,9 +295,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
280295
}
281296
case kADNCIMessageTrusted:
282297
{
283-
devices[device_identifier] = { device_ptr->device_info, nullptr };
284-
result[kEventString] = kDeviceTrusted;
285-
get_device_properties(device_identifier, result);
298+
on_device_found(device_ptr, device_identifier, kDeviceTrusted, result);
286299
break;
287300
}
288301
}

0 commit comments

Comments
 (0)