From 0480584865f0ce32cc9172a2e6468a7e991b46f5 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sat, 7 Jun 2025 12:11:59 +0200 Subject: idevicebackup2: Use new idevice_get_device_version helper --- tools/idevicebackup2.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 1a767cd..34b9739 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -1468,8 +1468,6 @@ static void print_usage(int argc, char **argv, int is_error) ); } -#define DEVICE_VERSION(maj, min, patch) ((((maj) & 0xFF) << 16) | (((min) & 0xFF) << 8) | ((patch) & 0xFF)) - int main(int argc, char *argv[]) { idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; @@ -1849,23 +1847,7 @@ int main(int argc, char *argv[]) } /* get ProductVersion */ - char *product_version = NULL; - int device_version = 0; - node_tmp = NULL; - lockdownd_get_value(lockdown, NULL, "ProductVersion", &node_tmp); - if (node_tmp) { - if (plist_get_node_type(node_tmp) == PLIST_STRING) { - plist_get_string_val(node_tmp, &product_version); - } - plist_free(node_tmp); - node_tmp = NULL; - } - if (product_version) { - int vers[3] = { 0, 0, 0 }; - if (sscanf(product_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) { - device_version = DEVICE_VERSION(vers[0], vers[1], vers[2]); - } - } + int device_version = idevice_get_device_version(device); /* start notification_proxy */ ldret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); @@ -2065,7 +2047,7 @@ checkpoint: } else { PRINT_VERBOSE(1, "Incremental backup mode.\n"); } - if (device_version >= DEVICE_VERSION(16,1,0)) { + if (device_version >= IDEVICE_DEVICE_VERSION(16,1,0)) { /* let's wait 2 second to see if the device passcode is requested */ int retries = 20; while (retries-- > 0 && !passcode_requested) { @@ -2246,7 +2228,7 @@ checkpoint: if (newpw || backup_password) { mobilebackup2_send_message(mobilebackup2, "ChangePassword", opts); uint8_t passcode_hint = 0; - if (device_version >= DEVICE_VERSION(13,0,0)) { + if (device_version >= IDEVICE_DEVICE_VERSION(13,0,0)) { diagnostics_relay_client_t diag = NULL; if (diagnostics_relay_client_start_service(device, &diag, TOOL_NAME) == DIAGNOSTICS_RELAY_E_SUCCESS) { plist_t dict = NULL; -- cgit v1.1-32-gdbae