From 358ecd1933bc307d8b8ab91770464bc466aee8e7 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 29 May 2017 16:37:34 +0300 Subject: [PATCH 1/2] Clean house arrest service when app is uninstalled Remove the house arrest service when app is uninstalled or device is removed. This fixes behavior when in a long living process, after app is uninstalled from device, trying to upload a new file using the old connection is not valid. --- IOSDeviceLib/IOSDeviceLib.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/IOSDeviceLib/IOSDeviceLib.cpp b/IOSDeviceLib/IOSDeviceLib.cpp index a35d2e8..dae30ce 100644 --- a/IOSDeviceLib/IOSDeviceLib.cpp +++ b/IOSDeviceLib/IOSDeviceLib.cpp @@ -198,16 +198,16 @@ void cleanup_file_resources(const std::string& device_identifier, const std::str return; } - afc_connection* afc_connection_to_close = nullptr; if (devices[device_identifier].apps_cache[application_identifier].afc_connection) { - afc_connection_to_close = devices[device_identifier].apps_cache[application_identifier].afc_connection; + afc_connection* afc_connection_to_close = devices[device_identifier].apps_cache[application_identifier].afc_connection; + AFCConnectionClose(afc_connection_to_close); + devices[device_identifier].apps_cache.erase(application_identifier); } - if (afc_connection_to_close) + if (devices[device_identifier].services.count(kHouseArrest)) { - AFCConnectionClose(afc_connection_to_close); - devices[device_identifier].apps_cache.erase(application_identifier); + devices[device_identifier].services.erase(kHouseArrest); } } @@ -355,7 +355,7 @@ HANDLE start_service(std::string device_identifier, const char* service_name, st { if (should_log_error) print_error("Device not found", device_identifier, method_id, kAMDNotFoundError); - + start_service_mutex.unlock(); return NULL; } @@ -378,7 +378,7 @@ HANDLE start_service(std::string device_identifier, const char* service_name, st message += service_name; if (should_log_error) print_error(message.c_str(), device_identifier, method_id, result); - + start_service_mutex.unlock(); return NULL; } @@ -1073,7 +1073,7 @@ void post_notification(std::string device_identifier, PostNotificationInfo post_ "" "" ""; - + SOCKET socket = (SOCKET)handle; send_message(xml_command.str().c_str(), socket); print(json({ { kResponse, socket }, { kId, method_id }, { kDeviceId, device_identifier } })); @@ -1263,7 +1263,7 @@ void connect_to_port(std::string device_identifier, int port, std::string method sockaddr_in server_address = server_socket_data->server_address; unsigned short port = ntohs(server_address.sin_port); socklen_t address_length = sizeof(server_address); - + // Return the host address and the port to the client. print(json({ { kHost, kLocalhostAddress }, { kPort, port }, { kId, method_id }, { kDeviceId, device_identifier } })); From 151307626a1c0e0743ae3ea893612d7ba2979322 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 29 May 2017 16:39:21 +0300 Subject: [PATCH 2/2] Set version to 0.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a11ad8..ef5730f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ios-device-lib", - "version": "0.4.1", + "version": "0.4.2", "description": "", "types": "./typings/ios-device-lib.d.ts", "main": "index.js",