forked from duhovny/DeviceHardware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeviceHardware.m
344 lines (332 loc) · 26.9 KB
/
DeviceHardware.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
//
// DeviceHardware.m
//
#import "DeviceHardware.h"
#include <sys/types.h>
#include <sys/sysctl.h>
#define DH_MACHINE_IPHONE_1_1 @"iPhone1,1"
#define DH_MACHINE_IPHONE_1_2 @"iPhone1,2"
#define DH_MACHINE_IPHONE_2_1 @"iPhone2,1"
#define DH_MACHINE_IPHONE_3_1 @"iPhone3,1"
#define DH_MACHINE_IPHONE_3_3 @"iPhone3,3"
#define DH_MACHINE_IPHONE_4_1 @"iPhone4,1"
#define DH_MACHINE_IPHONE_5_1 @"iPhone5,1"
#define DH_MACHINE_IPHONE_5_2 @"iPhone5,2"
#define DH_MACHINE_IPHONE_5_3 @"iPhone5,3"
#define DH_MACHINE_IPHONE_5_4 @"iPhone5,4"
#define DH_MACHINE_IPHONE_6_1 @"iPhone6,1"
#define DH_MACHINE_IPHONE_6_2 @"iPhone6,2"
#define DH_MACHINE_IPHONE_7_1 @"iPhone7,1"
#define DH_MACHINE_IPHONE_7_2 @"iPhone7,2"
#define DH_MACHINE_IPHONE_8_1 @"iPhone8,1"
#define DH_MACHINE_IPHONE_8_2 @"iPhone8,2"
#define DH_MACHINE_IPHONE_8_4 @"iPhone8,4"
#define DH_MACHINE_IPHONE_9_1 @"iPhone9,1"
#define DH_MACHINE_IPHONE_9_2 @"iPhone9,2"
#define DH_MACHINE_IPHONE_9_3 @"iPhone9,3"
#define DH_MACHINE_IPHONE_9_4 @"iPhone9,4"
#define DH_MACHINE_IPOD_1_1 @"iPod1,1"
#define DH_MACHINE_IPOD_2_1 @"iPod2,1"
#define DH_MACHINE_IPOD_3_1 @"iPod3,1"
#define DH_MACHINE_IPOD_4_1 @"iPod4,1"
#define DH_MACHINE_IPOD_5_1 @"iPod5,1"
#define DH_MACHINE_IPOD_7_1 @"iPod7,1"
#define DH_MACHINE_IPAD_1_1 @"iPad1,1"
#define DH_MACHINE_IPAD_2_1 @"iPad2,1"
#define DH_MACHINE_IPAD_2_2 @"iPad2,2"
#define DH_MACHINE_IPAD_2_3 @"iPad2,3"
#define DH_MACHINE_IPAD_2_4 @"iPad2,4"
#define DH_MACHINE_IPAD_2_5 @"iPad2,5"
#define DH_MACHINE_IPAD_2_6 @"iPad2,6"
#define DH_MACHINE_IPAD_2_7 @"iPad2,7"
#define DH_MACHINE_IPAD_3_1 @"iPad3,1"
#define DH_MACHINE_IPAD_3_2 @"iPad3,2"
#define DH_MACHINE_IPAD_3_3 @"iPad3,3"
#define DH_MACHINE_IPAD_3_4 @"iPad3,4"
#define DH_MACHINE_IPAD_3_5 @"iPad3,5"
#define DH_MACHINE_IPAD_3_6 @"iPad3,6"
#define DH_MACHINE_IPAD_4_1 @"iPad4,1"
#define DH_MACHINE_IPAD_4_2 @"iPad4,2"
#define DH_MACHINE_IPAD_4_3 @"iPad4,3"
#define DH_MACHINE_IPAD_4_4 @"iPad4,4"
#define DH_MACHINE_IPAD_4_5 @"iPad4,5"
#define DH_MACHINE_IPAD_4_6 @"iPad4,6"
#define DH_MACHINE_IPAD_4_7 @"iPad4,7"
#define DH_MACHINE_IPAD_4_8 @"iPad4,8"
#define DH_MACHINE_IPAD_4_9 @"iPad4,9"
#define DH_MACHINE_IPAD_5_1 @"iPad5,1"
#define DH_MACHINE_IPAD_5_2 @"iPad5,2"
#define DH_MACHINE_IPAD_5_3 @"iPad5,3"
#define DH_MACHINE_IPAD_5_4 @"iPad5,4"
#define DH_MACHINE_IPAD_6_3 @"iPad6,3"
#define DH_MACHINE_IPAD_6_4 @"iPad6,4"
#define DH_MACHINE_IPAD_6_7 @"iPad6,7"
#define DH_MACHINE_IPAD_6_8 @"iPad6,8"
#define DH_MACHINE_I386 @"i386"
#define DH_MACHINE_X86_64 @"x86_64"
@implementation DeviceHardware
+ (DeviceHardwareSpecificPlatform)specificPlatform {
NSString *platform = [self machine];
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_1]) return DeviceHardwareSpecificPlatform_iPhone_1G;
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_2]) return DeviceHardwareSpecificPlatform_iPhone_3G;
if ([platform isEqualToString:DH_MACHINE_IPHONE_2_1]) return DeviceHardwareSpecificPlatform_iPhone_3GS;
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_1]) return DeviceHardwareSpecificPlatform_iPhone_4;
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_3]) return DeviceHardwareSpecificPlatform_iPhone_4_Verizon;
if ([platform isEqualToString:DH_MACHINE_IPHONE_4_1]) return DeviceHardwareSpecificPlatform_iPhone_4S;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_1]) return DeviceHardwareSpecificPlatform_iPhone_5_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_2]) return DeviceHardwareSpecificPlatform_iPhone_5_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_3]) return DeviceHardwareSpecificPlatform_iPhone_5C_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_4]) return DeviceHardwareSpecificPlatform_iPhone_5C_Global;
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_1]) return DeviceHardwareSpecificPlatform_iPhone_5S_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_2]) return DeviceHardwareSpecificPlatform_iPhone_5S_Global;
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_1]) return DeviceHardwareSpecificPlatform_iPhone_6_Plus_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_2]) return DeviceHardwareSpecificPlatform_iPhone_6_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_1]) return DeviceHardwareSpecificPlatform_iPhone_6S_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_2]) return DeviceHardwareSpecificPlatform_iPhone_6S_Plus_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_4]) return DeviceHardwareSpecificPlatform_iPhone_SE_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_1]) return DeviceHardwareSpecificPlatform_iPhone_7_CDMA;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_2]) return DeviceHardwareSpecificPlatform_iPhone_7_Plus_CDMA;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_3]) return DeviceHardwareSpecificPlatform_iPhone_7_GSM;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_4]) return DeviceHardwareSpecificPlatform_iPhone_7_Plus_GSM;
if ([platform isEqualToString:DH_MACHINE_IPOD_1_1]) return DeviceHardwareSpecificPlatform_iPod_Touch_1G;
if ([platform isEqualToString:DH_MACHINE_IPOD_2_1]) return DeviceHardwareSpecificPlatform_iPod_Touch_2G;
if ([platform isEqualToString:DH_MACHINE_IPOD_3_1]) return DeviceHardwareSpecificPlatform_iPod_Touch_3G;
if ([platform isEqualToString:DH_MACHINE_IPOD_4_1]) return DeviceHardwareSpecificPlatform_iPod_Touch_4G;
if ([platform isEqualToString:DH_MACHINE_IPOD_5_1]) return DeviceHardwareSpecificPlatform_iPod_Touch_5G;
if ([platform isEqualToString:DH_MACHINE_IPOD_7_1]) return DeviceHardwareSpecificPlatform_iPod_Touch_6G;
if ([platform isEqualToString:DH_MACHINE_IPAD_1_1]) return DeviceHardwareSpecificPlatform_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_1]) return DeviceHardwareSpecificPlatform_iPad_2_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_2]) return DeviceHardwareSpecificPlatform_iPad_2_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_3]) return DeviceHardwareSpecificPlatform_iPad_2_CDMA;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_4]) return DeviceHardwareSpecificPlatform_iPad_2_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_5]) return DeviceHardwareSpecificPlatform_iPad_Mini_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_6]) return DeviceHardwareSpecificPlatform_iPad_Mini_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_7]) return DeviceHardwareSpecificPlatform_iPad_Mini_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_1]) return DeviceHardwareSpecificPlatform_iPad_3_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_2]) return DeviceHardwareSpecificPlatform_iPad_3_CDMA;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_3]) return DeviceHardwareSpecificPlatform_iPad_3_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_4]) return DeviceHardwareSpecificPlatform_iPad_4_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_5]) return DeviceHardwareSpecificPlatform_iPad_4_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_6]) return DeviceHardwareSpecificPlatform_iPad_4_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_1]) return DeviceHardwareSpecificPlatform_iPad_Air_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_2]) return DeviceHardwareSpecificPlatform_iPad_Air_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_3]) return DeviceHardwareSpecificPlatform_iPad_Air_TD_LTE_China;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_4]) return DeviceHardwareSpecificPlatform_iPad_Mini_2_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_5]) return DeviceHardwareSpecificPlatform_iPad_Mini_2_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_6]) return DeviceHardwareSpecificPlatform_iPad_Mini_2_TD_LTE_China;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_7]) return DeviceHardwareSpecificPlatform_iPad_Mini_3_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_8]) return DeviceHardwareSpecificPlatform_iPad_Mini_3_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_9]) return DeviceHardwareSpecificPlatform_iPad_Mini_3_TD_LTE_China;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_1]) return DeviceHardwareSpecificPlatform_iPad_Mini_4_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_2]) return DeviceHardwareSpecificPlatform_iPad_Mini_4_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_3]) return DeviceHardwareSpecificPlatform_iPad_Air_2_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_4]) return DeviceHardwareSpecificPlatform_iPad_Air_2_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_3]) return DeviceHardwareSpecificPlatform_iPad_Pro_9_7_inch_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_4]) return DeviceHardwareSpecificPlatform_iPad_Pro_9_7_inch_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_7]) return DeviceHardwareSpecificPlatform_iPad_Pro_12_9_inch_WiFi;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_8]) return DeviceHardwareSpecificPlatform_iPad_Pro_12_9_inch_CDMA_GSM;
if ([platform isEqualToString:DH_MACHINE_I386]) return DeviceHardwareSpecificPlatform_Simulator;
if ([platform isEqualToString:DH_MACHINE_X86_64]) return DeviceHardwareSpecificPlatform_Simulator;
return DeviceHardwareSpecificPlatform_Unknown;
}
+ (DeviceHardwareGeneralPlatform)generalPlatform {
NSString *platform = [self machine];
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_1]) return DeviceHardwareGeneralPlatform_iPhone_1G;
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_2]) return DeviceHardwareGeneralPlatform_iPhone_3G;
if ([platform isEqualToString:DH_MACHINE_IPHONE_2_1]) return DeviceHardwareGeneralPlatform_iPhone_3GS;
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_1]) return DeviceHardwareGeneralPlatform_iPhone_4;
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_3]) return DeviceHardwareGeneralPlatform_iPhone_4;
if ([platform isEqualToString:DH_MACHINE_IPHONE_4_1]) return DeviceHardwareGeneralPlatform_iPhone_4S;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_1]) return DeviceHardwareGeneralPlatform_iPhone_5;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_2]) return DeviceHardwareGeneralPlatform_iPhone_5;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_3]) return DeviceHardwareGeneralPlatform_iPhone_5C;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_4]) return DeviceHardwareGeneralPlatform_iPhone_5C;
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_1]) return DeviceHardwareGeneralPlatform_iPhone_5S;
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_2]) return DeviceHardwareGeneralPlatform_iPhone_5S;
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_1]) return DeviceHardwareGeneralPlatform_iPhone_6_Plus;
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_2]) return DeviceHardwareGeneralPlatform_iPhone_6;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_1]) return DeviceHardwareGeneralPlatform_iPhone_6S;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_2]) return DeviceHardwareGeneralPlatform_iPhone_6S_Plus;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_4]) return DeviceHardwareGeneralPlatform_iPhone_SE;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_1]) return DeviceHardwareGeneralPlatform_iPhone_7;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_2]) return DeviceHardwareGeneralPlatform_iPhone_7_Plus;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_3]) return DeviceHardwareGeneralPlatform_iPhone_7;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_4]) return DeviceHardwareGeneralPlatform_iPhone_7_Plus;
if ([platform isEqualToString:DH_MACHINE_IPOD_1_1]) return DeviceHardwareGeneralPlatform_iPod_Touch_1G;
if ([platform isEqualToString:DH_MACHINE_IPOD_2_1]) return DeviceHardwareGeneralPlatform_iPod_Touch_2G;
if ([platform isEqualToString:DH_MACHINE_IPOD_3_1]) return DeviceHardwareGeneralPlatform_iPod_Touch_3G;
if ([platform isEqualToString:DH_MACHINE_IPOD_4_1]) return DeviceHardwareGeneralPlatform_iPod_Touch_4G;
if ([platform isEqualToString:DH_MACHINE_IPOD_5_1]) return DeviceHardwareGeneralPlatform_iPod_Touch_5G;
if ([platform isEqualToString:DH_MACHINE_IPAD_1_1]) return DeviceHardwareGeneralPlatform_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_1]) return DeviceHardwareGeneralPlatform_iPad_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_2]) return DeviceHardwareGeneralPlatform_iPad_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_3]) return DeviceHardwareGeneralPlatform_iPad_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_4]) return DeviceHardwareGeneralPlatform_iPad_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_5]) return DeviceHardwareGeneralPlatform_iPad_Mini;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_6]) return DeviceHardwareGeneralPlatform_iPad_Mini;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_7]) return DeviceHardwareGeneralPlatform_iPad_Mini;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_1]) return DeviceHardwareGeneralPlatform_iPad_3;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_2]) return DeviceHardwareGeneralPlatform_iPad_3;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_3]) return DeviceHardwareGeneralPlatform_iPad_3;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_4]) return DeviceHardwareGeneralPlatform_iPad_4;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_5]) return DeviceHardwareGeneralPlatform_iPad_4;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_6]) return DeviceHardwareGeneralPlatform_iPad_4;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_1]) return DeviceHardwareGeneralPlatform_iPad_Air;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_2]) return DeviceHardwareGeneralPlatform_iPad_Air;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_3]) return DeviceHardwareGeneralPlatform_iPad_Air;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_4]) return DeviceHardwareGeneralPlatform_iPad_Mini_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_5]) return DeviceHardwareGeneralPlatform_iPad_Mini_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_6]) return DeviceHardwareGeneralPlatform_iPad_Mini_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_7]) return DeviceHardwareGeneralPlatform_iPad_Mini_3;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_8]) return DeviceHardwareGeneralPlatform_iPad_Mini_3;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_9]) return DeviceHardwareGeneralPlatform_iPad_Mini_3;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_1]) return DeviceHardwareGeneralPlatform_iPad_Mini_4;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_2]) return DeviceHardwareGeneralPlatform_iPad_Mini_4;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_3]) return DeviceHardwareGeneralPlatform_iPad_Air_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_4]) return DeviceHardwareGeneralPlatform_iPad_Air_2;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_3]) return DeviceHardwareGeneralPlatform_iPad_Pro_9_7_inch;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_4]) return DeviceHardwareGeneralPlatform_iPad_Pro_9_7_inch;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_7]) return DeviceHardwareGeneralPlatform_iPad_Pro_12_9_inch;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_8]) return DeviceHardwareGeneralPlatform_iPad_Pro_12_9_inch;
if ([platform isEqualToString:DH_MACHINE_I386]) return DeviceHardwareGeneralPlatform_Simulator;
if ([platform isEqualToString:DH_MACHINE_X86_64]) return DeviceHardwareGeneralPlatform_Simulator;
return DeviceHardwareGeneralPlatform_Unknown;
}
+ (DeviceHardwarePlatformType)platformType {
NSString *platform = [self machine];
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_2]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_2_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_3]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_4_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_2]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_3]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_4]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_2]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_2]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_2]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_4]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_1]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_2]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_3]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_4]) return DeviceHardwarePlatformType_iPhone;
if ([platform isEqualToString:DH_MACHINE_IPOD_1_1]) return DeviceHardwarePlatformType_iPod_Touch;
if ([platform isEqualToString:DH_MACHINE_IPOD_2_1]) return DeviceHardwarePlatformType_iPod_Touch;
if ([platform isEqualToString:DH_MACHINE_IPOD_3_1]) return DeviceHardwarePlatformType_iPod_Touch;
if ([platform isEqualToString:DH_MACHINE_IPOD_4_1]) return DeviceHardwarePlatformType_iPod_Touch;
if ([platform isEqualToString:DH_MACHINE_IPOD_5_1]) return DeviceHardwarePlatformType_iPod_Touch;
if ([platform isEqualToString:DH_MACHINE_IPOD_7_1]) return DeviceHardwarePlatformType_iPod_Touch;
if ([platform isEqualToString:DH_MACHINE_IPAD_1_1]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_1]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_2]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_3]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_4]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_5]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_6]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_2_7]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_1]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_2]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_3]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_4]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_5]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_3_6]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_1]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_2]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_3]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_4]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_5]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_6]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_7]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_8]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_4_9]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_1]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_2]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_3]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_5_4]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_3]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_4]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_7]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_IPAD_6_8]) return DeviceHardwarePlatformType_iPad;
if ([platform isEqualToString:DH_MACHINE_I386]) return DeviceHardwarePlatformType_Simulator;
if ([platform isEqualToString:DH_MACHINE_X86_64]) return DeviceHardwarePlatformType_Simulator;
return DeviceHardwarePlatformType_Unknown;
}
+ (NSString *)platformString {
NSString *platform = [self machine];
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_1]) return @"iPhone 1G";
if ([platform isEqualToString:DH_MACHINE_IPHONE_1_2]) return @"iPhone 3G";
if ([platform isEqualToString:DH_MACHINE_IPHONE_2_1]) return @"iPhone 3GS";
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_1]) return @"iPhone 4";
if ([platform isEqualToString:DH_MACHINE_IPHONE_3_3]) return @"iPhone 4 (Verizon)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_4_1]) return @"iPhone 4S";
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_1]) return @"iPhone 5 (GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_2]) return @"iPhone 5 (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_3]) return @"iPhone 5C (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_5_4]) return @"iPhone 5C (Global)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_1]) return @"iPhone 5S (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_6_2]) return @"iPhone 5S (Global)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_1]) return @"iPhone 6 Plus (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_7_2]) return @"iPhone 6 (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_1]) return @"iPhone 6S (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_2]) return @"iPhone 6S Plus (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_8_4]) return @"iPhone SE (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_1]) return @"iPhone 7 (CDMA)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_2]) return @"iPhone 7 Plus (CDMA)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_3]) return @"iPhone 7 (GSM)";
if ([platform isEqualToString:DH_MACHINE_IPHONE_9_4]) return @"iPhone 7 Plus (GSM)";
if ([platform isEqualToString:DH_MACHINE_IPOD_1_1]) return @"iPod Touch 1G";
if ([platform isEqualToString:DH_MACHINE_IPOD_2_1]) return @"iPod Touch 2G";
if ([platform isEqualToString:DH_MACHINE_IPOD_3_1]) return @"iPod Touch 3G";
if ([platform isEqualToString:DH_MACHINE_IPOD_4_1]) return @"iPod Touch 4G";
if ([platform isEqualToString:DH_MACHINE_IPOD_5_1]) return @"iPod Touch 5G";
if ([platform isEqualToString:DH_MACHINE_IPOD_7_1]) return @"iPod Touch 6G";
if ([platform isEqualToString:DH_MACHINE_IPAD_1_1]) return @"iPad";
if ([platform isEqualToString:DH_MACHINE_IPAD_2_1]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_2_2]) return @"iPad 2 (GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_2_3]) return @"iPad 2 (CDMA)";
if ([platform isEqualToString:DH_MACHINE_IPAD_2_4]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_2_5]) return @"iPad Mini (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_2_6]) return @"iPad Mini (GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_2_7]) return @"iPad Mini (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_3_1]) return @"iPad 3 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_3_2]) return @"iPad 3 (CDMA)";
if ([platform isEqualToString:DH_MACHINE_IPAD_3_3]) return @"iPad 3 (GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_3_4]) return @"iPad 4 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_3_5]) return @"iPad 4 (GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_3_6]) return @"iPad 4 (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_1]) return @"iPad Air (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_2]) return @"iPad Air (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_3]) return @"iPad Air (China)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_4]) return @"iPad Mini 2 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_5]) return @"iPad Mini 2 (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_6]) return @"iPad Mini 2 (China)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_7]) return @"iPad Mini 3 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_8]) return @"iPad Mini 3 (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_4_9]) return @"iPad Mini 3 (China)";
if ([platform isEqualToString:DH_MACHINE_IPAD_5_1]) return @"iPad Mini 4 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_5_2]) return @"iPad Mini 4 (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_5_3]) return @"iPad Air 2 (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_5_4]) return @"iPad Air 2 (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_6_3]) return @"iPad Pro 9.7 inch (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_6_4]) return @"iPad Pro 9.7 inch (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_IPAD_6_7]) return @"iPad Pro 12.9 inch (WiFi)";
if ([platform isEqualToString:DH_MACHINE_IPAD_6_8]) return @"iPad Pro 12.9 inch (CDMA+GSM)";
if ([platform isEqualToString:DH_MACHINE_I386]) return @"Simulator";
if ([platform isEqualToString:DH_MACHINE_X86_64]) return @"Simulator";
return platform;
}
+ (NSString *)machine {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
}
@end