From 7a761f179f6964177e390a9001e600f40ed22994 Mon Sep 17 00:00:00 2001 From: Greg Bellows Date: Tue, 18 Nov 2014 16:31:31 -0600 Subject: android-console: Add base avd command support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add base Android emulator console avd command support and associated help message. Signed-off-by: Greg Bellows Reviewed-by: Alex Bennée [AJB: fixed up sub-table] Signed-off-by: Alex Bennée --- android-commands.h | 11 +++++++++++ android-console.c | 30 ++++++++++++++++++++++++++++++ android-console.h | 2 ++ 3 files changed, 43 insertions(+) diff --git a/android-commands.h b/android-commands.h index c8119effe..abd798a80 100644 --- a/android-commands.h +++ b/android-commands.h @@ -103,6 +103,10 @@ static mon_cmd_t android_event_cmds[] = { { NULL, NULL, }, }; +static mon_cmd_t android_avd_cmds[] = { + { NULL, NULL, }, +}; + static mon_cmd_t android_cmds[] = { { .name = "help|h|?", @@ -147,5 +151,12 @@ static mon_cmd_t android_cmds[] = { .mhandler.cmd = android_console_event, .sub_cmds.static_table = android_event_cmds, }, + { .name = "avd", + .args_type = "item:s?", + .params = "", + .help = "control virtual device execution", + .mhandler.cmd = android_console_avd, + .sub_cmds.static_table = android_avd_cmds, + }, { NULL, NULL, }, }; diff --git a/android-console.c b/android-console.c index f2f2ff227..8875824bf 100644 --- a/android-console.c +++ b/android-console.c @@ -726,3 +726,33 @@ void android_console_event(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%s\n%s\n", event_help[cmd], helptext ? "OK" : "KO: missing sub-command"); } + +enum { + CMD_AVD, +}; + +static const char *avd_help[] = { + /* CMD_AVD */ + "allows you to control (e.g. start/stop) the execution of the virtual " + "device\n" + "\n" + "available sub-commands:\n" + " avd stop stop the virtual device\n" + " avd start start/restart the virtual device\n" + " avd status query virtual device status\n" + " avd name query virtual device name\n" + " avd snapshot state snapshot commands\n", +}; + +void android_console_avd(Monitor *mon, const QDict *qdict) +{ + /* This only gets called for bad subcommands and help requests */ + const char *helptext = qdict_get_try_str(qdict, "helptext"); + + /* Default to the first entry which is the parent help message */ + int cmd = CMD_AVD; + + /* If this is not a help request then we are here with a bad sub-command */ + monitor_printf(mon, "%s\n%s\n", avd_help[cmd], + helptext ? "OK" : "KO: missing sub-command"); +} diff --git a/android-console.h b/android-console.h index 4cb9ad4e6..67a1bf6e7 100644 --- a/android-console.h +++ b/android-console.h @@ -42,6 +42,8 @@ void android_console_event_send(Monitor *mon, const QDict *qdict); void android_console_event_text(Monitor *mon, const QDict *qdict); void android_console_event(Monitor *mon, const QDict *qdict); +void android_console_avd(Monitor *mon, const QDict *qdict); + void android_monitor_print_error(Monitor *mon, const char *fmt, ...); #endif -- cgit v1.2.3