diff mbox

[v1,05/15] android-console: Add console base power command

Message ID 1415751963-4081-6-git-send-email-greg.bellows@linaro.org
State New
Headers show

Commit Message

Greg Bellows Nov. 12, 2014, 12:25 a.m. UTC
Added the base Android emulator console power command and infrastructure for
adding sub-commands.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
---
 android-commands.h | 11 +++++++++++
 android-console.c  | 16 ++++++++++++++++
 android-console.h  |  2 ++
 3 files changed, 29 insertions(+)
diff mbox

Patch

diff --git a/android-commands.h b/android-commands.h
index 1bfd15d..29c8769 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_table = android_redir_cmds,
     },
+    {   .name = "power",
+        .args_type = "item:s?",
+        .params = "",
+        .help = "power related commands",
+        .mhandler.cmd = android_console_power,
+        .sub_table = android_power_cmds,
+    },
     { NULL, NULL, },
 };
diff --git a/android-console.c b/android-console.c
index 0be5949..c08c607 100644
--- a/android-console.c
+++ b/android-console.c
@@ -298,3 +298,19 @@  void android_console_redir(Monitor *mon, const QDict *qdict)
     monitor_printf(mon, "%s\n", redir_help[cmd]);
 }
 
+enum {
+    CMD_POWER,
+};
+
+static const char *power_help[] = {
+        /* CMD_POWER */
+        "allows to change battery and AC power status",
+};
+
+void android_console_power(Monitor *mon, const QDict *qdict)
+{
+    /* Default to the first entry which is the parent help message */
+    int cmd = CMD_POWER;
+
+    monitor_printf(mon, "%s\n", power_help[cmd]);
+}
diff --git a/android-console.h b/android-console.h
index 2786b64..ba936be 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