summaryrefslogtreecommitdiffstats
path: root/src/normal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/normal.c b/src/normal.c
index 15d3e29..efe8f03 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -29,6 +29,7 @@
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libimobiledevice/preboard.h>
+#include <usbmuxd.h>
#include "common.h"
#include "normal.h"
@@ -41,6 +42,7 @@ static int normal_idevice_new(struct idevicerestore_client_t* client, idevice_t*
idevice_t dev = NULL;
idevice_error_t device_error;
lockdownd_client_t lockdown = NULL;
+ plist_t node = NULL;
*device = NULL;
@@ -65,6 +67,10 @@ static int normal_idevice_new(struct idevicerestore_client_t* client, idevice_t*
return -1;
}
free(type);
+ if (lockdownd_get_value(lockdown, NULL, "UniqueChipID", &node) == LOCKDOWN_E_SUCCESS) {
+ plist_get_uint_val(node, &client->ecid);
+ plist_free(node);
+ }
lockdownd_client_free(lockdown);
lockdown = NULL;
@@ -107,7 +113,7 @@ static int normal_idevice_new(struct idevicerestore_client_t* client, idevice_t*
}
free(type);
- plist_t node = NULL;
+ node = NULL;
if ((lockdownd_get_value(lockdown, NULL, "UniqueChipID", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_UINT)){
if (node) {
plist_free(node);
@@ -228,12 +234,6 @@ int normal_enter_recovery(struct idevicerestore_client_t* client)
return -1;
}
- /* unpair the device */
- lockdown_error = lockdownd_unpair(lockdown, NULL);
- if (lockdown_error != LOCKDOWN_E_SUCCESS) {
- error("WARNING: Could not unpair device\n");
- }
-
lockdown_error = lockdownd_enter_recovery(lockdown);
if (lockdown_error == LOCKDOWN_E_SESSION_INACTIVE) {
lockdownd_client_free(lockdown);
@@ -280,6 +280,9 @@ int normal_enter_recovery(struct idevicerestore_client_t* client)
return -1;
}
+ /* remove pair record for given device */
+ usbmuxd_delete_pair_record(client->udid);
+
return 0;
}
@@ -320,7 +323,7 @@ plist_t normal_get_lockdown_value(struct idevicerestore_client_t* client, const
return node;
}
-static int normal_get_nonce_by_key(struct idevicerestore_client_t* client, const char* key, unsigned char** nonce, int* nonce_size)
+static int normal_get_nonce_by_key(struct idevicerestore_client_t* client, const char* key, unsigned char** nonce, unsigned int* nonce_size)
{
plist_t nonce_node = normal_get_lockdown_value(client, NULL, key);
@@ -331,18 +334,18 @@ static int normal_get_nonce_by_key(struct idevicerestore_client_t* client, const
uint64_t n_size = 0;
plist_get_data_val(nonce_node, (char**)nonce, &n_size);
- *nonce_size = (int)n_size;
+ *nonce_size = (unsigned int)n_size;
plist_free(nonce_node);
return 0;
}
-int normal_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size)
+int normal_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, unsigned int* nonce_size)
{
return normal_get_nonce_by_key(client, "SEPNonce", nonce, nonce_size);
}
-int normal_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size)
+int normal_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, unsigned int* nonce_size)
{
return normal_get_nonce_by_key(client, "ApNonce", nonce, nonce_size);
}
@@ -362,27 +365,26 @@ int normal_is_image4_supported(struct idevicerestore_client_t* client)
return bval;
}
-int normal_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid)
+int normal_get_preflight_info(struct idevicerestore_client_t* client, plist_t *preflight_info)
{
- plist_t unique_chip_node = normal_get_lockdown_value(client, NULL, "UniqueChipID");
- if (!unique_chip_node || plist_get_node_type(unique_chip_node) != PLIST_UINT) {
- error("ERROR: Unable to get ECID\n");
- return -1;
- }
- plist_get_uint_val(unique_chip_node, ecid);
- plist_free(unique_chip_node);
+ uint8_t has_telephony_capability = 0;
+ plist_t node;
- return 0;
-}
+ node = normal_get_lockdown_value(client, NULL, "TelephonyCapability");
+ plist_get_bool_val(node, &has_telephony_capability);
+ plist_free(node);
-int normal_get_preflight_info(struct idevicerestore_client_t* client, plist_t *preflight_info)
-{
- plist_t node = normal_get_lockdown_value(client, NULL, "FirmwarePreflightInfo");
- if (!node || plist_get_node_type(node) != PLIST_DICT) {
- error("ERROR: Unable to get FirmwarePreflightInfo\n");
- return -1;
+ if (has_telephony_capability) {
+ node = normal_get_lockdown_value(client, NULL, "FirmwarePreflightInfo");
+ if (!node || plist_get_node_type(node) != PLIST_DICT) {
+ error("ERROR: Unable to get FirmwarePreflightInfo\n");
+ return -1;
+ }
+ *preflight_info = node;
+ } else {
+ debug("DEBUG: Device does not have TelephonyCapability, no FirmwarePreflightInfo\n");
+ *preflight_info = NULL;
}
- *preflight_info = node;
return 0;
}
@@ -577,7 +579,6 @@ int normal_handle_commit_stashbag(struct idevicerestore_client_t* client, plist_
if (perr != PREBOARD_E_SUCCESS) {
error("ERROR: could not receive from preboard service (%d)\n", perr);
} else {
- int commit_complete = 0;
plist_t node = plist_dict_get_item(pl, "Error");
if (node) {
char *strval = NULL;