From a6e94923cf409af5f9d63297785882302bc628ae Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 16:51:27 -0700 Subject: [PATCH] Fixes #170 - ios-deploy installing over both USB and WiFi --- src/MobileDevice.h | 4 ++++ src/ios-deploy.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/MobileDevice.h b/src/MobileDevice.h index d97eafb..8c9ff91 100644 --- a/src/MobileDevice.h +++ b/src/MobileDevice.h @@ -195,6 +195,10 @@ mach_error_t AMDeviceNotificationSubscribe(am_device_notification_callback callback, unsigned int unused0, unsigned int unused1, void* //unsigned int dn_unknown3, struct am_device_notification **notification); + +mach_error_t AMDeviceNotificationUnsubscribe(am_device_notification subscription); + + /* Connects to the iPhone. Pass in the am_device structure that the * notification callback will give to you. * diff --git a/src/ios-deploy.c b/src/ios-deploy.c index 3ad9b25..a2ddd19 100644 --- a/src/ios-deploy.c +++ b/src/ios-deploy.c @@ -180,6 +180,7 @@ pid_t child = 0; const int SIGLLDB = SIGUSR1; AMDeviceRef best_device_match = NULL; NSString* tmpUUID; +struct am_device_notification *notify; // Error codes we report on different failures, so scripts can distinguish between user app exit // codes and our exit codes. For non app errors we use codes in reserved 128-255 range. @@ -1709,7 +1710,8 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar switch (info->msg) { case ADNCI_MSG_CONNECTED: if(device_id != NULL || !debug || AMDeviceGetInterfaceType(info->dev) != 2) { - handle_device(info->dev); + AMDeviceNotificationUnsubscribe(*notify); + handle_device(info->dev); } else if(best_device_match == NULL) { best_device_match = info->dev; CFRetain(best_device_match); @@ -1962,7 +1964,6 @@ int main(int argc, char *argv[]) { NSLogOut(@"[....] Waiting for iOS device to be connected"); } - struct am_device_notification *notify; AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, ¬ify); CFRunLoopRun(); }