Skip to content

Commit c86d933

Browse files
Update device detection json output to include the interface over which the device was found (e.g. Wifi, USB, etc) and to correctly start a session before fetching device attributes. Previously without a session, devices connected over wifi would return null for some attributes including BuildVersion and DeviceClass.
1 parent 8670979 commit c86d933

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/ios-deploy/ios-deploy.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ device_desc get_device_desc(CFStringRef model) {
456456
return res;
457457
}
458458

459+
void connect_and_start_session(AMDeviceRef device) {
460+
AMDeviceConnect(device);
461+
assert(AMDeviceIsPaired(device));
462+
check_error(AMDeviceValidatePairing(device));
463+
check_error(AMDeviceStartSession(device));
464+
}
465+
459466
CFStringRef get_device_full_name(const AMDeviceRef device) {
460467
CFStringRef full_name = NULL,
461468
device_udid = AMDeviceCopyDeviceIdentifier(device),
@@ -521,7 +528,7 @@ CFStringRef get_device_full_name(const AMDeviceRef device) {
521528

522529
NSDictionary* get_device_json_dict(const AMDeviceRef device) {
523530
NSMutableDictionary *json_dict = [NSMutableDictionary new];
524-
AMDeviceConnect(device);
531+
connect_and_start_session(device);
525532

526533
CFStringRef device_udid = AMDeviceCopyDeviceIdentifier(device);
527534
if (device_udid) {
@@ -1214,13 +1221,6 @@ void fdvendor_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataR
12141221
CFRelease(s);
12151222
}
12161223

1217-
void connect_and_start_session(AMDeviceRef device) {
1218-
AMDeviceConnect(device);
1219-
assert(AMDeviceIsPaired(device));
1220-
check_error(AMDeviceValidatePairing(device));
1221-
check_error(AMDeviceStartSession(device));
1222-
}
1223-
12241224
void start_remote_debug_server(AMDeviceRef device) {
12251225

12261226
dbgServiceConnection = NULL;
@@ -2539,6 +2539,7 @@ void handle_device(AMDeviceRef device) {
25392539
if (detect_only) {
25402540
if (_json_output) {
25412541
NSLogJSON(@{@"Event": @"DeviceDetected",
2542+
@"Interface": (__bridge NSString *)device_interface_name,
25422543
@"Device": get_device_json_dict(device)
25432544
});
25442545
} else {
@@ -2770,6 +2771,7 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar
27702771
NSLogVerbose(@"[....] Disconnected %@ from %@.", device_uuid, device_interface_name);
27712772
if (detect_only && _json_output) {
27722773
NSLogJSON(@{@"Event": @"DeviceDisconnected",
2774+
@"Interface": (__bridge NSString *)device_interface_name,
27732775
@"Device": get_device_json_dict(info->dev)
27742776
});
27752777
}

0 commit comments

Comments
 (0)