From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlb-0002Bc-Pr for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoLlU-0000Nm-SA for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:35 -0500 Received: from mail-oi0-f54.google.com ([209.85.218.54]:37327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlU-0000Mz-Ne for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:28 -0500 Received: by mail-oi0-f54.google.com with SMTP id i138so386399oig.13 for ; Tue, 11 Nov 2014 16:26:28 -0800 (PST) From: Greg Bellows Date: Tue, 11 Nov 2014 18:26:01 -0600 Message-Id: <1415751963-4081-14-git-send-email-greg.bellows@linaro.org> In-Reply-To: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> References: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> Subject: [Qemu-devel] [PATCH v1 13/15] android-console: Add power present command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org, alex.bennee@linaro.org Cc: Greg Bellows Add the Android emulator console "power present" command and associated help messages. The "present" command allows the battery presence in the device to be manipulated. Signed-off-by: Greg Bellows --- android-commands.h | 7 +++++++ android-console.c | 23 +++++++++++++++++++++++ android-console.h | 1 + 3 files changed, 31 insertions(+) diff --git a/android-commands.h b/android-commands.h index 53f89b1..3adef55 100644 --- a/android-commands.h +++ b/android-commands.h @@ -47,6 +47,13 @@ static mon_cmd_t android_power_cmds[] = { .help = "set battery status", .mhandler.cmd = android_console_power_status, }, + { + .name = "present", + .args_type = "arg:s?", + .params = "", + .help = "set battery present state", + .mhandler.cmd = android_console_power_present, + }, { NULL, NULL, }, }; diff --git a/android-console.c b/android-console.c index 04a1971..b08519d 100644 --- a/android-console.c +++ b/android-console.c @@ -356,12 +356,30 @@ void android_console_power_status(Monitor *mon, const QDict *qdict) "discharging|not-charging|full\"\n"); } +void android_console_power_present(Monitor *mon, const QDict *qdict) +{ + const char *arg = qdict_get_try_str(qdict, "arg"); + + if (arg) { + if (strcasecmp(arg, "true") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_PRESENT, 1); + return; + } + if (strcasecmp(arg, "false") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_PRESENT, 0); + return; + } + } + + monitor_printf(mon, "KO: Usage: \"present true\" or \"present false\"\n"); +} enum { CMD_POWER, CMD_POWER_DISPLAY, CMD_POWER_AC, CMD_POWER_STATUS, + CMD_POWER_PRESENT, }; static const char *power_help[] = { @@ -374,6 +392,9 @@ static const char *power_help[] = { /* CMD_POWER_STATUS */ "'status unknown|charging|discharging|not-charging|full' allows you " "to set battery status", + /* CMD_POWER_PRESENT */ + "'present true|false' allows you to set battery present state to true " + "or false", }; void android_console_power(Monitor *mon, const QDict *qdict) @@ -391,6 +412,8 @@ void android_console_power(Monitor *mon, const QDict *qdict) cmd = CMD_POWER_AC; } else if (strstr(helptext, "status")) { cmd = CMD_POWER_STATUS; + } else if (strstr(helptext, "present")) { + cmd = CMD_POWER_PRESENT; } } diff --git a/android-console.h b/android-console.h index 184ae69..c7c7c86 100644 --- a/android-console.h +++ b/android-console.h @@ -31,6 +31,7 @@ void android_console_redir_del(Monitor *mon, const QDict *qdict); void android_console_power_display(Monitor *mon, const QDict *qdict); void android_console_power_ac(Monitor *mon, const QDict *qdict); void android_console_power_status(Monitor *mon, const QDict *qdict); +void android_console_power_present(Monitor *mon, const QDict *qdict); void android_console_power(Monitor *mon, const QDict *qdict); void android_monitor_print_error(Monitor *mon, const char *fmt, ...); -- 1.8.3.2