diff options
author | Greg Bellows <greg.bellows@linaro.org> | 2014-11-19 14:52:56 -0600 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2015-01-07 11:36:05 +0000 |
commit | 02612bb68ac6ddc70062600abe36e683f6c8c3d5 (patch) | |
tree | d076704f3eb9b3b358e96d6a65f8c394e6a294c3 | |
parent | 106fa5d2f605bdb54a2f8394aab97c8035585d58 (diff) | |
download | qemu-android-02612bb68ac6ddc70062600abe36e683f6c8c3d5.tar.gz |
android-console: Add power display command
Add the Android emulator console "power display" along with the associated help
messages. The "display" command allows the current device power and battery state
to be displayed.
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
-rw-r--r-- | android-commands.h | 7 | ||||
-rw-r--r-- | android-console.c | 18 | ||||
-rw-r--r-- | android-console.h | 1 |
3 files changed, 26 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h index 145a01a6fb..67e3c4634d 100644 --- a/android-commands.h +++ b/android-commands.h @@ -26,6 +26,13 @@ static mon_cmd_t android_redir_cmds[] = { }; static mon_cmd_t android_power_cmds[] = { + { + .name = "display", + .args_type = "", + .params = "", + .help = "display battery and charger state", + .mhandler.cmd = android_console_power_display, + }, { NULL, NULL, }, }; diff --git a/android-console.c b/android-console.c index f54c50b49a..b1d1389cef 100644 --- a/android-console.c +++ b/android-console.c @@ -21,6 +21,7 @@ #include "net/slirp.h" #include "slirp/libslirp.h" #include "qmp-commands.h" +#include "hw/misc/goldfish_battery.h" typedef struct { int is_udp; @@ -306,8 +307,16 @@ void android_console_redir(Monitor *mon, const QDict *qdict) helptext ? "OK" : "KO: missing sub-command"); } +void android_console_power_display(Monitor *mon, const QDict *qdict) +{ + goldfish_battery_display(mon); + + monitor_printf(mon, "OK\n"); +} + enum { CMD_POWER, + CMD_POWER_DISPLAY, }; static const char *power_help[] = { @@ -321,6 +330,8 @@ static const char *power_help[] = { " power present set battery present state\n" " power health set battery health state\n" " power capacity set battery capacity state\n", + /* CMD_POWER_DISPLAY */ + "display battery and charger state", }; void android_console_power(Monitor *mon, const QDict *qdict) @@ -331,7 +342,14 @@ void android_console_power(Monitor *mon, const QDict *qdict) /* Default to the first entry which is the parent help message */ int cmd = CMD_POWER; + if (helptext) { + if (strstr(helptext, "display")) { + cmd = CMD_POWER_DISPLAY; + } + } + /* 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 ba936be6a5..44ff11b010 100644 --- a/android-console.h +++ b/android-console.h @@ -28,6 +28,7 @@ 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_display(Monitor *mon, const QDict *qdict); void android_console_power(Monitor *mon, const QDict *qdict); void android_monitor_print_error(Monitor *mon, const char *fmt, ...); |