|
91 | 91 | mach_error_t AMDeviceLookupApplications(AMDeviceRef device, CFDictionaryRef options, CFDictionaryRef *result);
|
92 | 92 | int AMDeviceGetInterfaceType(AMDeviceRef device);
|
93 | 93 | AMDeviceRef AMDeviceCopyPairedCompanion(AMDeviceRef device);
|
| 94 | +#if defined(IOS_DEPLOY_FEATURE_DEVELOPER_MODE) |
| 95 | +unsigned int AMDeviceCopyDeveloperModeStatus(AMDeviceRef device, uint32_t *error_code); |
| 96 | +#endif |
94 | 97 |
|
95 | 98 | int AMDServiceConnectionSend(ServiceConnRef con, const void * data, size_t size);
|
96 | 99 | int AMDServiceConnectionReceive(ServiceConnRef con, void * data, size_t size);
|
@@ -2289,6 +2292,34 @@ void uninstall_app(AMDeviceRef device) {
|
2289 | 2292 | }
|
2290 | 2293 | }
|
2291 | 2294 |
|
| 2295 | +#if defined(IOS_DEPLOY_FEATURE_DEVELOPER_MODE) |
| 2296 | +void check_developer_mode(AMDeviceRef device) { |
| 2297 | + unsigned int error_code = 0; |
| 2298 | + bool is_enabled = AMDeviceCopyDeveloperModeStatus(device, &error_code); |
| 2299 | + |
| 2300 | + if (error_code) { |
| 2301 | + const char *mobdev_error = get_error_message(error_code); |
| 2302 | + NSString *error_description = mobdev_error ? [NSString stringWithUTF8String:mobdev_error] : @"unknown."; |
| 2303 | + if (_json_output) { |
| 2304 | + NSLogJSON(@{ |
| 2305 | + @"Event": @"DeveloperMode", |
| 2306 | + @"IsEnabled": @(is_enabled), |
| 2307 | + @"Code": @(error_code), |
| 2308 | + @"Status": error_description, |
| 2309 | + }); |
| 2310 | + } else { |
| 2311 | + NSLogOut(@"Encountered error checking developer mode status: %@", error_description); |
| 2312 | + } |
| 2313 | + } else { |
| 2314 | + if (_json_output) { |
| 2315 | + NSLogJSON(@{@"Event": @"DeveloperMode", @"IsEnabled": @(is_enabled)}); |
| 2316 | + } else { |
| 2317 | + NSLogOut(@"Developer mode is%s enabled.", is_enabled ? "" : " not"); |
| 2318 | + } |
| 2319 | + } |
| 2320 | +} |
| 2321 | +#endif |
| 2322 | + |
2292 | 2323 | void start_symbols_service_with_command(AMDeviceRef device, uint32_t command) {
|
2293 | 2324 | connect_and_start_session(device);
|
2294 | 2325 | check_error(AMDeviceSecureStartService(device, symbols_service_name,
|
@@ -2608,7 +2639,11 @@ void handle_device(AMDeviceRef device) {
|
2608 | 2639 | uninstall_provisioning_profile(device);
|
2609 | 2640 | } else if (strcmp("download_profile", command) == 0) {
|
2610 | 2641 | download_provisioning_profile(device);
|
2611 |
| - } |
| 2642 | +#if defined(IOS_DEPLOY_FEATURE_DEVELOPER_MODE) |
| 2643 | + } else if (strcmp("check_developer_mode", command) == 0) { |
| 2644 | + check_developer_mode(device); |
| 2645 | +#endif |
| 2646 | + } |
2612 | 2647 | exit(0);
|
2613 | 2648 | }
|
2614 | 2649 |
|
@@ -2874,7 +2909,12 @@ void usage(const char* app) {
|
2874 | 2909 | @" --profile-uuid <uuid> the UUID of the provisioning profile to target, use with other profile commands\n"
|
2875 | 2910 | @" --profile-download <path> download a provisioning profile (requires --profile-uuid)\n"
|
2876 | 2911 | @" --profile-install <file> install a provisioning profile\n"
|
2877 |
| - @" --profile-uninstall uninstall a provisioning profile (requires --profile-uuid <UUID>)\n", |
| 2912 | + @" --profile-uninstall uninstall a provisioning profile (requires --profile-uuid <UUID>)\n" |
| 2913 | +#if defined(IOS_DEPLOY_FEATURE_DEVELOPER_MODE) |
| 2914 | + @" --check-developer-mode checks whether the given device has developer mode enabled (requires Xcode 14 or newer)\n", |
| 2915 | +#else |
| 2916 | + , |
| 2917 | +#endif |
2878 | 2918 | [NSString stringWithUTF8String:app]);
|
2879 | 2919 | }
|
2880 | 2920 |
|
@@ -2940,6 +2980,9 @@ int main(int argc, char *argv[]) {
|
2940 | 2980 | { "profile-uninstall", no_argument, NULL, 1005},
|
2941 | 2981 | { "profile-download", required_argument, NULL, 1006},
|
2942 | 2982 | { "profile-uuid", required_argument, NULL, 1007},
|
| 2983 | +#if defined(IOS_DEPLOY_FEATURE_DEVELOPER_MODE) |
| 2984 | + { "check-developer-mode", no_argument, NULL, 1008}, |
| 2985 | +#endif |
2943 | 2986 | { NULL, 0, NULL, 0 },
|
2944 | 2987 | };
|
2945 | 2988 | int ch;
|
@@ -3115,6 +3158,12 @@ int main(int argc, char *argv[]) {
|
3115 | 3158 | case 1007:
|
3116 | 3159 | profile_uuid = optarg;
|
3117 | 3160 | break;
|
| 3161 | +#if defined(IOS_DEPLOY_FEATURE_DEVELOPER_MODE) |
| 3162 | + case 1008: |
| 3163 | + command_only = true; |
| 3164 | + command = "check_developer_mode"; |
| 3165 | + break; |
| 3166 | +#endif |
3118 | 3167 | case 'P':
|
3119 | 3168 | command_only = true;
|
3120 | 3169 | command = "list_profiles";
|
|
0 commit comments