diff options
author | INSUN PYO <insun.pyo@samsung.com> | 2017-06-22 14:24:58 +0900 |
---|---|---|
committer | INSUN PYO <insun.pyo@samsung.com> | 2017-06-22 14:53:20 +0900 |
commit | 524dbbbf313bda840ca8d6e02abe8674536d605f (patch) | |
tree | ff28b50369ab6960d1e799e956fdf68dabd6319b | |
parent | af1e5a6073c0fc0e1eb556492a5c80c2b8082c66 (diff) | |
download | device-manager-plugin-emul-524dbbbf313bda840ca8d6e02abe8674536d605f.tar.gz device-manager-plugin-emul-524dbbbf313bda840ca8d6e02abe8674536d605f.tar.bz2 device-manager-plugin-emul-524dbbbf313bda840ca8d6e02abe8674536d605f.zip |
battery : read fails /sys/class/power_supply/battery/capacity at the first access time.tizen_4.0.m2_releasetizen_4.0.IoT.p2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_4.0/20170828.110001submit/tizen_4.0/20170811.094300submit/tizen/20170623.065932accepted/tizen/unified/20170626.011735accepted/tizen/4.0/unified/20170828.224128accepted/tizen/4.0/unified/20170816.012212tizen_4.0accepted/tizen_4.0_unified
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.c | 12 |
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); |