summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2017-06-22 14:24:58 +0900
committerINSUN PYO <insun.pyo@samsung.com>2017-06-22 14:53:20 +0900
commit524dbbbf313bda840ca8d6e02abe8674536d605f (patch)
treeff28b50369ab6960d1e799e956fdf68dabd6319b
parentaf1e5a6073c0fc0e1eb556492a5c80c2b8082c66 (diff)
downloaddevice-manager-plugin-emul-524dbbbf313bda840ca8d6e02abe8674536d605f.tar.gz
device-manager-plugin-emul-524dbbbf313bda840ca8d6e02abe8674536d605f.tar.bz2
device-manager-plugin-emul-524dbbbf313bda840ca8d6e02abe8674536d605f.zip
When the TW emulator first accesses /sys/class/power_supply/battery/capacity, it sometimes returns an empty string. So, lowbat_monitor() is called with 0 parameter. "0" means that battery level is 0. When deviced detects battery level 0, it creates a 30 second power off timer. So the emulator automatically powers off intermittently after 35 seconds. If an empty string is returned, we modify it to read /sys/clas/power_supply/battery/capacity again. Signed-off-by: INSUN PYO <insun.pyo@samsung.com> Change-Id: Ieefd950fe175ef138814624f6a3957ac7432cc74
-rw-r--r--hw/battery/battery.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/battery/battery.c b/hw/battery/battery.c
index 5f16019..583a5c3 100644
--- a/hw/battery/battery.c
+++ b/hw/battery/battery.c
@@ -176,6 +176,18 @@ static int battery_get_current_state(
_E("Failed to get value of (%s, %d)", FILE_BATTERY_CAPACITY, ret);
return ret;
}
+
+ /* When the TW emulator first accesses /sys/class/power_supply/battery/capacity,
+ it sometimes returns an empty string. */
+ if (capacity_str[0] == 0) {
+ _E("/sys/class/power_supply/battery/capacity returns null string, retry read it again");
+ ret = sys_get_str(FILE_BATTERY_CAPACITY, capacity_str, sizeof(capacity_str));
+ if (ret < 0) {
+ _E("Failed to get value of (%s, %d)", FILE_BATTERY_CAPACITY, ret);
+ return ret;
+ }
+ }
+
ret = sys_get_str(FILE_BATTERY_CHARGER_ONLINE, charger_str, sizeof(charger_str));
if (ret < 0) {
_E("Failed to get value of (%s, %d)", FILE_BATTERY_CHARGER_ONLINE, ret);