summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Bellows <greg.bellows@linaro.org>2014-11-19 14:52:56 -0600
committerGreg Bellows <greg.bellows@linaro.org>2014-11-19 15:27:26 -0600
commite3f71038fd59febd25b345e689fd8139766cfdd7 (patch)
tree7a5a6d59f3d91726d35c859f6b9fdb0697d1c258
parent376194a7a48acfb030d1bbb72988569613fdfb40 (diff)
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.h7
-rw-r--r--android-console.c18
-rw-r--r--android-console.h1
3 files changed, 26 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h
index 29c8769b8..8bf856d99 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 f54c50b49..b1d1389ce 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 ba936be6a..44ff11b01 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, ...);