Skip to content

Commit

Permalink
ideviceactivation: Add new 'state' command to query device for activa…
Browse files Browse the repository at this point in the history
…tion state
  • Loading branch information
nikias committed Mar 15, 2018
1 parent 6c7a2c0 commit 0c59a88
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tools/ideviceactivation.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static void print_usage(int argc, char **argv)
printf("Where COMMAND is one of:\n");
printf(" activate\t\tattempt to activate the device\n");
printf(" deactivate\t\tdeactivate the device\n");
printf(" state\t\t\tquery device about its activation state\n");
printf("\nThe following OPTIONS are accepted:\n");
printf(" -d, --debug\t\tenable communication debugging\n");
printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n");
Expand Down Expand Up @@ -80,7 +81,7 @@ int main(int argc, char *argv[])
int result = EXIT_FAILURE;

typedef enum {
OP_NONE = 0, OP_ACTIVATE, OP_DEACTIVATE
OP_NONE = 0, OP_ACTIVATE, OP_DEACTIVATE, OP_GETSTATE
} op_t;
op_t op = OP_NONE;

Expand Down Expand Up @@ -125,6 +126,10 @@ int main(int argc, char *argv[])
op = OP_DEACTIVATE;
continue;
}
else if (!strcmp(argv[i], "state")) {
op = OP_GETSTATE;
continue;
}
else {
print_usage(argc, argv);
return EXIT_SUCCESS;
Expand Down Expand Up @@ -465,6 +470,23 @@ int main(int argc, char *argv[])
result = EXIT_SUCCESS;
printf("Successfully activated device.\n");
break;
case OP_GETSTATE: {
plist_t state = NULL;
if (use_mobileactivation) {
mobileactivation_get_activation_state(ma, &state);
} else {
lockdownd_get_value(lockdown, NULL, "ActivationState", &state);
}
if (plist_get_node_type(state) == PLIST_STRING) {
char *s_state = NULL;
plist_get_string_val(state, &s_state);
printf("ActivationState: %s\n", s_state);
free(s_state);
} else {
printf("Error getting activation state.\n");
}
}
break;
}

cleanup:
Expand Down

0 comments on commit 0c59a88

Please sign in to comment.