From patchwork Wed Nov 12 00:26:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 40631 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AA8B1205DF for ; Wed, 12 Nov 2014 00:35:42 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id n3sf1310602wiv.5 for ; Tue, 11 Nov 2014 16:35:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Qmp9tns2yB/qWiPid9PYTtN0FWhAy+1yesOGjEi5Xj8=; b=DdUTos0RmadiQwUeaxz7i6iQPqWzXt46pQcwMJPjO5Q2sESYzN/Ij1Dc00mRmrw0cQ +8TKhjc+jNxFeROaJJ4/OReMdMfjH1jigMLTqKAucWhf3FD++xVxweZm2HUTx5G2p4cw EBINC63oMjkQEIXVNf0ZRepHeF6mwk/fuIuR5X5d/qLoclTwxvKafKQJofHYFnV2SoY1 LhjLqTUvGGswixTXl6do0Xg+AaokCEl7dK7vA37O9v/cFQnpfljLfXw4DF8iY2oAmmbn AucD6u1YVERCpX/4suTC+DddenvxM9qThLong7ZY8nAGL9m8kidru06gCQKlDODeLAq6 jQ1w== X-Gm-Message-State: ALoCoQky3hFAJf1RfVRq+jOyYt2zKQqaG/XLUUW3G8eFdx6q30eKenNHmciHyjBxKUZfXqgpwa5T X-Received: by 10.180.94.3 with SMTP id cy3mr5930795wib.7.1415752541993; Tue, 11 Nov 2014 16:35:41 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.121.72 with SMTP id li8ls687435lab.101.gmail; Tue, 11 Nov 2014 16:35:41 -0800 (PST) X-Received: by 10.112.200.34 with SMTP id jp2mr39203819lbc.1.1415752541834; Tue, 11 Nov 2014 16:35:41 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id b8si13698170laf.116.2014.11.11.16.35.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:35:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gm9so10584188lab.33 for ; Tue, 11 Nov 2014 16:35:41 -0800 (PST) X-Received: by 10.112.167.200 with SMTP id zq8mr39107115lbb.61.1415752541717; Tue, 11 Nov 2014 16:35:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp347784lbc; Tue, 11 Nov 2014 16:35:40 -0800 (PST) X-Received: by 10.140.38.102 with SMTP id s93mr55662553qgs.8.1415752540303; Tue, 11 Nov 2014 16:35:40 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d8si39334108qaq.40.2014.11.11.16.35.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:35:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:51629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLuN-0007tN-FZ for patch@linaro.org; Tue, 11 Nov 2014 19:35:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlb-0002By-VV 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 1XoLlV-0000OD-Po for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:35 -0500 Received: from mail-oi0-f44.google.com ([209.85.218.44]:34510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlV-0000O9-K9 for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:29 -0500 Received: by mail-oi0-f44.google.com with SMTP id h136so7870067oig.17 for ; Tue, 11 Nov 2014 16:26:29 -0800 (PST) X-Received: by 10.182.163.33 with SMTP id yf1mr35795078obb.0.1415751989325; Tue, 11 Nov 2014 16:26:29 -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.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:26:28 -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:02 -0600 Message-Id: <1415751963-4081-15-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.218.44 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH v1 14/15] android-console: Add power health 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add the Android emulator console "power health" command and associated help messages. The "health" command allows the battery health of the device to be manipulated. Signed-off-by: Greg Bellows --- android-commands.h | 7 +++++++ android-console.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ android-console.h | 1 + 3 files changed, 55 insertions(+) diff --git a/android-commands.h b/android-commands.h index 3adef55..bb3f783 100644 --- a/android-commands.h +++ b/android-commands.h @@ -54,6 +54,13 @@ static mon_cmd_t android_power_cmds[] = { .help = "set battery present state", .mhandler.cmd = android_console_power_present, }, + { + .name = "health", + .args_type = "arg:s?", + .params = "", + .help = "set battery health state", + .mhandler.cmd = android_console_power_health, + }, { NULL, NULL, }, }; diff --git a/android-console.c b/android-console.c index b08519d..0a4fc1d 100644 --- a/android-console.c +++ b/android-console.c @@ -374,12 +374,54 @@ void android_console_power_present(Monitor *mon, const QDict *qdict) monitor_printf(mon, "KO: Usage: \"present true\" or \"present false\"\n"); } +void android_console_power_health(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_HEALTH, + POWER_SUPPLY_HEALTH_UNKNOWN); + return; + } + if (strcasecmp(arg, "good") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_HEALTH_GOOD); + return; + } + if (strcasecmp(arg, "overheat") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_HEALTH_OVERHEAT); + return; + } + if (strcasecmp(arg, "dead") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_HEALTH_DEAD); + return; + } + if (strcasecmp(arg, "overvoltage") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_HEALTH_OVERVOLTAGE); + return; + } + if (strcasecmp(arg, "failure") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_HEALTH_UNSPEC_FAILURE); + return; + } + } + + monitor_printf(mon, "KO: Usage: \"health unknown|good|overheat|" + "dead|overvoltage|failure\"\n"); +} + enum { CMD_POWER, CMD_POWER_DISPLAY, CMD_POWER_AC, CMD_POWER_STATUS, CMD_POWER_PRESENT, + CMD_POWER_HEALTH, }; static const char *power_help[] = { @@ -395,6 +437,9 @@ static const char *power_help[] = { /* CMD_POWER_PRESENT */ "'present true|false' allows you to set battery present state to true " "or false", + /* CMD_POWER_HEALTH */ + "'health unknown|good|overheat|dead|overvoltage|failure' allows you " + "to set battery health state", }; void android_console_power(Monitor *mon, const QDict *qdict) @@ -414,6 +459,8 @@ void android_console_power(Monitor *mon, const QDict *qdict) cmd = CMD_POWER_STATUS; } else if (strstr(helptext, "present")) { cmd = CMD_POWER_PRESENT; + } else if (strstr(helptext, "health")) { + cmd = CMD_POWER_HEALTH; } } diff --git a/android-console.h b/android-console.h index c7c7c86..aea671f 100644 --- a/android-console.h +++ b/android-console.h @@ -32,6 +32,7 @@ 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_health(Monitor *mon, const QDict *qdict); void android_console_power(Monitor *mon, const QDict *qdict); void android_monitor_print_error(Monitor *mon, const char *fmt, ...);