diff options
author | Greg Bellows <greg.bellows@linaro.org> | 2014-11-11 15:14:50 -0600 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2015-01-07 11:36:05 +0000 |
commit | 8ebc1b0a4c45adfca9675c54be27c5d5bb07982a (patch) | |
tree | 8b8a5ff24ab25dd38ddb628213c72e0aae57ba49 | |
parent | 47e15c10e0b26b0f2f2ddbd363c322d738276ddc (diff) | |
download | qemu-android-8ebc1b0a4c45adfca9675c54be27c5d5bb07982a.tar.gz |
android-console: Add power present command
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 <greg.bellows@linaro.org>
---
v2 -> v3
- Add missing "OK" messages
-rw-r--r-- | android-commands.h | 7 | ||||
-rw-r--r-- | android-console.c | 25 | ||||
-rw-r--r-- | android-console.h | 1 |
3 files changed, 33 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h index ce3ea59381..a13d95d56a 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 34db8187ef..6b04e76954 100644 --- a/android-console.c +++ b/android-console.c @@ -371,12 +371,32 @@ 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); + monitor_printf(mon, "OK\n"); + return; + } + if (strcasecmp(arg, "false") == 0) { + goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_PRESENT, 0); + monitor_printf(mon, "OK\n"); + 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[] = { @@ -397,6 +417,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) @@ -414,6 +437,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 184ae691a0..c7c7c86525 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, ...); |