summaryrefslogtreecommitdiff
path: root/src/activation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/activation.c')
-rw-r--r--src/activation.c93
1 files changed, 59 insertions, 34 deletions
diff --git a/src/activation.c b/src/activation.c
index 2a30295..dc2de9f 100644
--- a/src/activation.c
+++ b/src/activation.c
@@ -588,6 +588,9 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new
IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new_from_lockdownd(idevice_activation_client_type_t client_type, lockdownd_client_t lockdown, idevice_activation_request** request)
{
+ uint8_t has_telephony_capability = 0;
+ uint8_t has_mobile_equipment_id = 0;
+
// check arguments
if (!lockdown) {
return IDEVICE_ACTIVATION_E_INTERNAL_ERROR;
@@ -601,7 +604,8 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new
// add AppleSerialNumber
if ((lockdownd_get_value(lockdown, NULL, "SerialNumber", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
- fprintf(stderr, "%s: Unable to get SerialNumber from lockdownd\n", __func__);
+ if (debug_level > 0)
+ fprintf(stderr, "%s: Unable to get SerialNumber from lockdownd\n", __func__);
plist_free(fields);
return IDEVICE_ACTIVATION_E_INCOMPLETE_INFO;
} else {
@@ -612,48 +616,69 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new
node = NULL;
}
- // add IMEI
- if ((lockdownd_get_value(lockdown, NULL, "InternationalMobileEquipmentIdentity", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
- fprintf(stderr, "%s: Unable to get IMEI from lockdownd\n", __func__);
+ // check if device has telephone capability
+ if ((lockdownd_get_value(lockdown, NULL, "TelephonyCapability", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_BOOLEAN)) {
+ has_telephony_capability = 0;
} else {
- plist_dict_set_item(fields, "IMEI", plist_copy(node));
+ plist_get_bool_val(node, &has_telephony_capability);
}
if (node) {
plist_free(node);
node = NULL;
}
- // add MEID
- if ((lockdownd_get_value(lockdown, NULL, "MobileEquipmentIdentifier", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
- fprintf(stderr, "%s: Unable to get MEID from lockdownd\n", __func__);
- } else {
- plist_dict_set_item(fields, "MEID", plist_copy(node));
- }
- if (node) {
- plist_free(node);
- node = NULL;
- }
+ if (has_telephony_capability) {
+ // add IMEI
+ if ((lockdownd_get_value(lockdown, NULL, "InternationalMobileEquipmentIdentity", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
+ has_mobile_equipment_id = 0;
+ } else {
+ plist_dict_set_item(fields, "IMEI", plist_copy(node));
+ has_mobile_equipment_id = 1;
+ }
+ if (node) {
+ plist_free(node);
+ node = NULL;
+ }
- // add IMSI
- if ((lockdownd_get_value(lockdown, NULL, "InternationalMobileSubscriberIdentity", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
- fprintf(stderr, "%s: Unable to get IMSI from lockdownd\n", __func__);
- } else {
- plist_dict_set_item(fields, "IMSI", plist_copy(node));
- }
- if (node) {
- plist_free(node);
- node = NULL;
- }
+ // add MEID
+ if ((lockdownd_get_value(lockdown, NULL, "MobileEquipmentIdentifier", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
+ if (debug_level > 0)
+ fprintf(stderr, "%s: Unable to get MEID from lockdownd\n", __func__);
+ if (!has_mobile_equipment_id) {
+ plist_free(fields);
+ return IDEVICE_ACTIVATION_E_INCOMPLETE_INFO;
+ }
+ } else {
+ plist_dict_set_item(fields, "MEID", plist_copy(node));
+ }
+ if (node) {
+ plist_free(node);
+ node = NULL;
+ }
- // add ICCID
- if ((lockdownd_get_value(lockdown, NULL, "IntegratedCircuitCardIdentity", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
- fprintf(stderr, "%s: Unable to get ICCID from lockdownd\n", __func__);
- } else {
- plist_dict_set_item(fields, "ICCID", plist_copy(node));
- }
- if (node) {
- plist_free(node);
- node = NULL;
+ // add IMSI
+ if ((lockdownd_get_value(lockdown, NULL, "InternationalMobileSubscriberIdentity", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
+ if (debug_level > 0)
+ fprintf(stderr, "%s: Unable to get IMSI from lockdownd\n", __func__);
+ } else {
+ plist_dict_set_item(fields, "IMSI", plist_copy(node));
+ }
+ if (node) {
+ plist_free(node);
+ node = NULL;
+ }
+
+ // add ICCID
+ if ((lockdownd_get_value(lockdown, NULL, "IntegratedCircuitCardIdentity", &node) != LOCKDOWN_E_SUCCESS) || !node || (plist_get_node_type(node) != PLIST_STRING)) {
+ if (debug_level > 0)
+ fprintf(stderr, "%s: Unable to get ICCID from lockdownd\n", __func__);
+ } else {
+ plist_dict_set_item(fields, "ICCID", plist_copy(node));
+ }
+ if (node) {
+ plist_free(node);
+ node = NULL;
+ }
}
// add activation-info