From patchwork Wed Nov 12 00:26:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 409789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2DF0414012C for ; Wed, 12 Nov 2014 11:34:39 +1100 (AEDT) Received: from localhost ([::1]:51620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLtN-0006uG-CE for incoming@patchwork.ozlabs.org; Tue, 11 Nov 2014 19:34:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlb-0002AJ-4a 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 1XoLlT-0000M0-VU for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:35 -0500 Received: from mail-ob0-f177.google.com ([209.85.214.177]:33518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlT-0000LV-QM for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:27 -0500 Received: by mail-ob0-f177.google.com with SMTP id m8so7949379obr.8 for ; Tue, 11 Nov 2014 16:26:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AiyargnT8z0wXXKtTYt86+EVBrMJHtJrUhI+I31DRj4=; b=aVsoPDDjBaOlQ7J3FIPq89rTOVS/roQMCJKx4DhBbs7un4xLkglNhOcec3J419hmTG 5g5zYXd2IxiLqmldaNSeCrab5qcOzqL+iWABBay97N5ktlgOEv8PUN6jLjTMA2pjCETh OybSy5CwjTJf1ifV6PjzVVQBQ48emev2yEPCNQxwhkqFaRg6Eq5UE9tJpxG6ZLwBTLjw MZ5vGe4bmyjoub7HMJ/FWx6Wlr84MUMWbzsPygVhtxlzJsGY1BuKW0DwG9x+KbxZI6fD kR9+hPOINg5szhcRCdMoPGm53xThLS5o9/N1O6LOX1Ck14LwFHKZivwHKMjlc6qzw5Fl cz4Q== X-Gm-Message-State: ALoCoQlrYao0vL13vsksi6/yUx3F0szEiOCIg43RcSn5vm2f0JBz9AVIIUX1IputzaT+Ppfp3r2R X-Received: by 10.202.188.6 with SMTP id m6mr33720501oif.26.1415751987466; Tue, 11 Nov 2014 16:26:27 -0800 (PST) Received: from gbellows-linaro.bellowshome.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id d3sm6239765obs.18.2014.11.11.16.26.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:26:26 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org, alex.bennee@linaro.org Date: Tue, 11 Nov 2014 18:26:00 -0600 Message-Id: <1415751963-4081-13-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> References: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.214.177 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH v1 12/15] android-console: Add power status command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add the Android emulator console "power status" command and associated help messages. The "status" command allows the battery status of the device to be manipulated. Signed-off-by: Greg Bellows --- android-commands.h | 7 +++++++ android-console.c | 39 +++++++++++++++++++++++++++++++++++++++ android-console.h | 1 + 3 files changed, 47 insertions(+) diff --git a/android-commands.h b/android-commands.h index 674e259..53f89b1 100644 --- a/android-commands.h +++ b/android-commands.h @@ -40,6 +40,13 @@ static mon_cmd_t android_power_cmds[] = { .help = "set AC charging state", .mhandler.cmd = android_console_power_ac, }, + { + .name = "status", + .args_type = "arg:s?", + .params = "", + .help = "set battery status", + .mhandler.cmd = android_console_power_status, + }, { NULL, NULL, }, }; diff --git a/android-console.c b/android-console.c index dbcc993..04a1971 100644 --- a/android-console.c +++ b/android-console.c @@ -324,10 +324,44 @@ void android_console_power_ac(Monitor *mon, const QDict *qdict) monitor_printf(mon, "KO: Usage: \"ac on\" or \"ac off\"\n"); } +void android_console_power_status(Monitor *mon, const QDict *qdict) +{ + const char *arg = qdict_get_try_str(qdict, "arg"); + + if (arg) { + if (strcasecmp(arg, "unknown") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_STATUS_UNKNOWN); + return; + } else if (strcasecmp(arg, "charging") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_STATUS_CHARGING); + return; + } else if (strcasecmp(arg, "discharging") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_STATUS_DISCHARGING); + return; + } else if (strcasecmp(arg, "not-charging") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_STATUS_NOT_CHARGING); + return; + } else if (strcasecmp(arg, "full") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_STATUS_FULL); + return; + } + } + + monitor_printf(mon, "KO: Usage: \"status unknown|charging|" + "discharging|not-charging|full\"\n"); +} + + enum { CMD_POWER, CMD_POWER_DISPLAY, CMD_POWER_AC, + CMD_POWER_STATUS, }; static const char *power_help[] = { @@ -337,6 +371,9 @@ static const char *power_help[] = { "display battery and charger state", /* CMD_POWER_AC */ "'ac on|off' allows you to set the AC charging state to on or off", + /* CMD_POWER_STATUS */ + "'status unknown|charging|discharging|not-charging|full' allows you " + "to set battery status", }; void android_console_power(Monitor *mon, const QDict *qdict) @@ -352,6 +389,8 @@ void android_console_power(Monitor *mon, const QDict *qdict) cmd = CMD_POWER_DISPLAY; } else if (strstr(helptext, "ac")) { cmd = CMD_POWER_AC; + } else if (strstr(helptext, "status")) { + cmd = CMD_POWER_STATUS; } } diff --git a/android-console.h b/android-console.h index 458f44c..184ae69 100644 --- a/android-console.h +++ b/android-console.h @@ -30,6 +30,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(Monitor *mon, const QDict *qdict); void android_monitor_print_error(Monitor *mon, const char *fmt, ...);