Skip to content

Commit

Permalink
List only devices connected by usb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Fatme committed Apr 10, 2018
1 parent 9986034 commit 4f819b7
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions IOSDeviceLib/IOSDeviceLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,23 @@ inline bool has_complete_status(std::map<std::string, boost::any>& dict)
return boost::any_cast<std::string>(dict[kStatusKey]) == kComplete;
}

void on_device_found(const DevicePointer* device_ptr, std::string device_identifier, std::string eventString, json &result)
{
/*
Interface type can be one of the followings:
-1 - invalid interface type
0 - unknown interface type
1 - usb interface type
2 - wifi interface type
*/
int interface_type = AMDeviceGetInterfaceType(device_ptr->device_info);
if (interface_type == kUSBInterfaceType) {
devices[device_identifier] = { device_ptr->device_info, nullptr };
result[kEventString] = eventString;
get_device_properties(device_identifier, result);
}
}

void device_notification_callback(const DevicePointer* device_ptr)
{
std::string device_identifier = get_cstring_from_cfstring(AMDeviceCopyDeviceIdentifier(device_ptr->device_info));
Expand All @@ -254,9 +271,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
{
case kADNCIMessageConnected:
{
devices[device_identifier] = { device_ptr->device_info, nullptr };
result[kEventString] = kDeviceFound;
get_device_properties(device_identifier, result);
on_device_found(device_ptr, device_identifier, kDeviceFound, result);
break;
}
case kADNCIMessageDisconnected:
Expand All @@ -280,9 +295,7 @@ void device_notification_callback(const DevicePointer* device_ptr)
}
case kADNCIMessageTrusted:
{
devices[device_identifier] = { device_ptr->device_info, nullptr };
result[kEventString] = kDeviceTrusted;
get_device_properties(device_identifier, result);
on_device_found(device_ptr, device_identifier, kDeviceTrusted, result);
break;
}
}
Expand Down

0 comments on commit 4f819b7

Please sign in to comment.