diff options
author | Greg Bellows <greg.bellows@linaro.org> | 2014-11-11 14:02:39 -0600 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2015-01-07 11:36:05 +0000 |
commit | 2fe6d2b75e0a750c873bbd481bd07d108cff2329 (patch) | |
tree | 5e86c168c68f2bd8d67727814c1bc4dff2deabd5 | |
parent | 15361fe54fdd32a780d70c9707f36eb940a03590 (diff) |
android-console: Add console base power command
Added the base Android emulator console power command and infrastructure for
adding sub-commands.
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
[AJB: fixed up sub-table]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
-rw-r--r-- | android-commands.h | 11 | ||||
-rw-r--r-- | android-console.c | 29 | ||||
-rw-r--r-- | android-console.h | 2 |
3 files changed, 42 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h index 3d1423483..145a01a6f 100644 --- a/android-commands.h +++ b/android-commands.h @@ -25,6 +25,10 @@ static mon_cmd_t android_redir_cmds[] = { { NULL, NULL, }, }; +static mon_cmd_t android_power_cmds[] = { + { NULL, NULL, }, +}; + static mon_cmd_t android_cmds[] = { { .name = "help|h|?", @@ -55,5 +59,12 @@ static mon_cmd_t android_cmds[] = { .mhandler.cmd = android_console_redir, .sub_cmds.static_table = android_redir_cmds, }, + { .name = "power", + .args_type = "item:s?", + .params = "", + .help = "power related commands", + .mhandler.cmd = android_console_power, + .sub_cmds.static_table = android_power_cmds, + }, { NULL, NULL, }, }; diff --git a/android-console.c b/android-console.c index da3f65cb8..f54c50b49 100644 --- a/android-console.c +++ b/android-console.c @@ -306,3 +306,32 @@ void android_console_redir(Monitor *mon, const QDict *qdict) helptext ? "OK" : "KO: missing sub-command"); } +enum { + CMD_POWER, +}; + +static const char *power_help[] = { + /* CMD_POWER */ + "allows to change battery and AC power status\n" + "\n" + "available sub-commands:\n" + " power display display battery and charger state\n" + " power ac set AC charging state\n" + " power status set battery status\n" + " power present set battery present state\n" + " power health set battery health state\n" + " power capacity set battery capacity state\n", +}; + +void android_console_power(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_POWER; + + /* If this is not a help request then we are here with a bad sub-command */ + monitor_printf(mon, "%s\n%s\n", power_help[cmd], + helptext ? "OK" : "KO: missing sub-command"); +} diff --git a/android-console.h b/android-console.h index 2786b64e0..ba936be6a 100644 --- a/android-console.h +++ b/android-console.h @@ -28,6 +28,8 @@ void android_console_redir_list(Monitor *mon, const QDict *qdict); void android_console_redir_add(Monitor *mon, const QDict *qdict); void android_console_redir_del(Monitor *mon, const QDict *qdict); +void android_console_power(Monitor *mon, const QDict *qdict); + void android_monitor_print_error(Monitor *mon, const char *fmt, ...); #endif |