Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update device detection json output to include the interface #554

Merged
merged 1 commit into from
May 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/ios-deploy/ios-deploy.m
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@ device_desc get_device_desc(CFStringRef model) {
return res;
}

void connect_and_start_session(AMDeviceRef device) {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device));
}

CFStringRef get_device_full_name(const AMDeviceRef device) {
CFStringRef full_name = NULL,
device_udid = AMDeviceCopyDeviceIdentifier(device),
Expand Down Expand Up @@ -521,7 +528,7 @@ CFStringRef get_device_full_name(const AMDeviceRef device) {

NSDictionary* get_device_json_dict(const AMDeviceRef device) {
NSMutableDictionary *json_dict = [NSMutableDictionary new];
AMDeviceConnect(device);
connect_and_start_session(device);

CFStringRef device_udid = AMDeviceCopyDeviceIdentifier(device);
if (device_udid) {
Expand Down Expand Up @@ -1214,13 +1221,6 @@ void fdvendor_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataR
CFRelease(s);
}

void connect_and_start_session(AMDeviceRef device) {
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
check_error(AMDeviceValidatePairing(device));
check_error(AMDeviceStartSession(device));
}

void start_remote_debug_server(AMDeviceRef device) {

dbgServiceConnection = NULL;
Expand Down Expand Up @@ -2539,6 +2539,7 @@ void handle_device(AMDeviceRef device) {
if (detect_only) {
if (_json_output) {
NSLogJSON(@{@"Event": @"DeviceDetected",
@"Interface": (__bridge NSString *)device_interface_name,
@"Device": get_device_json_dict(device)
});
} else {
Expand Down Expand Up @@ -2770,6 +2771,7 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar
NSLogVerbose(@"[....] Disconnected %@ from %@.", device_uuid, device_interface_name);
if (detect_only && _json_output) {
NSLogJSON(@{@"Event": @"DeviceDisconnected",
@"Interface": (__bridge NSString *)device_interface_name,
@"Device": get_device_json_dict(info->dev)
});
}
Expand Down