summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c198
1 files changed, 5 insertions, 193 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 6bdab05..b5ccd3d 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -1141,207 +1141,19 @@ int check_device(struct idevicerestore_client_t* client) {
case MODE_DFU:
case MODE_RECOVERY:
- if (get_cpid(client, &cpid) < 0) {
- error("ERROR: Unable to get device CPID\n");
- break;
- }
-
- switch (cpid) {
- case CPID_IPHONE2G:
- // iPhone1,1 iPhone1,2 and iPod1,1 all share the same ChipID
- // so we need to check the BoardID
- if (get_bdid(client, &bdid) < 0) {
- error("ERROR: Unable to get device BDID\n");
- break;
- }
-
- switch (bdid) {
- case BDID_IPHONE2G:
- device = DEVICE_IPHONE2G;
- break;
-
- case BDID_IPHONE3G:
- device = DEVICE_IPHONE3G;
- break;
-
- case BDID_IPOD1G:
- device = DEVICE_IPOD1G;
- break;
-
- default:
- device = DEVICE_UNKNOWN;
- break;
- }
- break;
-
- case CPID_IPHONE3GS:
- device = DEVICE_IPHONE3GS;
- break;
-
- case CPID_IPOD2G:
- device = DEVICE_IPOD2G;
- break;
-
- case CPID_IPOD3G:
- device = DEVICE_IPOD3G;
- break;
-
- case CPID_IPAD1G:
- // All the A4 devices are the same...BoardID'll solve that problem!
- if (get_bdid(client, &bdid) < 0) {
- error("ERROR: Unable to get device BDID\n");
- break;
- }
-
- switch (bdid) {
- case BDID_IPAD1G:
- device = DEVICE_IPAD1G;
- break;
-
- case BDID_IPHONE4:
- device = DEVICE_IPHONE4;
- break;
-
- case BDID_IPOD4G:
- device = DEVICE_IPOD4G;
- break;
-
- case BDID_APPLETV2:
- device = DEVICE_APPLETV2;
- break;
-
- case BDID_IPHONE42:
- device = DEVICE_IPHONE42;
- break;
-
- default:
- device = DEVICE_UNKNOWN;
- break;
- }
- break;
-
- case CPID_IPAD21:
- // All the A5 devices are the same too...
- if (get_bdid(client, &bdid) < 0) {
- error("ERROR: Unable to get device BDID\n");
- break;
- }
-
- switch (bdid) {
- case BDID_IPAD21:
- device = DEVICE_IPAD21;
- break;
-
- case BDID_IPAD22:
- device = DEVICE_IPAD22;
- break;
-
- case BDID_IPAD23:
- device = DEVICE_IPAD23;
- break;
-
- case BDID_IPHONE4S:
- device = DEVICE_IPHONE4S;
- break;
-
- default:
- device = DEVICE_UNKNOWN;
- break;
- }
- break;
-
- case CPID_APPLETV31:
- if (get_bdid(client, &bdid) < 0) {
- error("ERROR: Unable to get device BDID\n");
- break;
- }
- switch (bdid) {
- case BDID_APPLETV31:
- device = DEVICE_APPLETV31;
- break;
- case BDID_IPAD24:
- device = DEVICE_IPAD24;
- break;
- case BDID_IPAD25:
- device = DEVICE_IPAD25;
- break;
- case BDID_IPOD5G:
- device = DEVICE_IPOD5G;
- break;
- default:
- device = DEVICE_UNKNOWN;
- break;
- }
- break;
-
- case CPID_IPAD31:
- // A5X devices
- if (get_bdid(client, &bdid) < 0) {
- error("ERROR: Unable to get device BDID\n");
- break;
- }
- switch (bdid) {
- case BDID_IPAD31:
- device = DEVICE_IPAD31;
- break;
- case BDID_IPAD32:
- device = DEVICE_IPAD32;
- break;
- case BDID_IPAD33:
- device = DEVICE_IPAD33;
- break;
- default:
- device = DEVICE_UNKNOWN;
- break;
- }
- break;
-
- case CPID_IPHONE5:
- if (get_bdid(client, &bdid) < 0) {
- error("ERROR: Unable to get device BDID\n");
- break;
- }
- switch (bdid) {
- case BDID_IPHONE51:
- device = DEVICE_IPHONE51;
- break;
- case BDID_IPHONE52:
- device = DEVICE_IPHONE52;
- break;
- default:
- device = DEVICE_UNKNOWN;
- break;
- }
- break;
-
- case CPID_IPAD34:
- if (get_bdid(client, &bdid) < 0) {
- error("ERROR: Unable to get device BDID\n");
- break;
- }
- switch (bdid) {
- case BDID_IPAD34:
- device = DEVICE_IPAD34;
- break;
- default:
- device = DEVICE_UNKNOWN;
- break;
- }
- break;
-
- default:
+ device = dfu_check_device(client);
+ if (device < 0) {
device = DEVICE_UNKNOWN;
- break;
}
break;
-
default:
device = DEVICE_UNKNOWN;
break;
-
}
- client->device = &irecv_devices[device];
+ if (device != DEVICE_UNKNOWN)
+ client->device = &irecv_devices[device];
+
return device;
}