diff options
author | Nikias Bassen | 2018-03-15 01:05:49 +0100 |
---|---|---|
committer | Nikias Bassen | 2018-03-15 01:05:49 +0100 |
commit | 0c59a888d5a9da6fa23a6a2e74875e33c0dfff2f (patch) | |
tree | e9384349c27ef856906305247728e53eb5d514ce | |
parent | 6c7a2c08a1d9ac5db1a465f66d72360cdf6acd19 (diff) | |
download | libideviceactivation-0c59a888d5a9da6fa23a6a2e74875e33c0dfff2f.tar.gz libideviceactivation-0c59a888d5a9da6fa23a6a2e74875e33c0dfff2f.tar.bz2 |
ideviceactivation: Add new 'state' command to query device for activation state
-rw-r--r-- | tools/ideviceactivation.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/ideviceactivation.c b/tools/ideviceactivation.c index 1db2dc1..6fef4fb 100644 --- a/tools/ideviceactivation.c +++ b/tools/ideviceactivation.c @@ -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"); @@ -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; @@ -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; @@ -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: |