Add voltage and temperature data in uevent
authorlokilee73 <changjoo.lee@samsung.com>
Tue, 15 May 2018 02:34:32 +0000 (11:34 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 6 Jul 2018 10:40:33 +0000 (10:40 +0000)
Change-Id: I5238c313804d2cda6ebd1ca30b6eba32d1fdfedb
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/battery/battery.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 5751943..75f79ac
@@ -135,6 +135,21 @@ static void uevent_delivered(struct udev_device *dev)
                return;
        info.power_source = val;
 
+       val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_VOLTAGE_NOW");
+       if (!val)
+               return;
+       info.voltage_now = atoi(val); /* uV */
+
+       val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_VOLTAGE_AVG");
+       if (!val)
+               return;
+       info.voltage_average = atoi(val); /* uV */
+
+       val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_TEMP");
+       if (!val)
+               return;
+       info.temperature = atoi(val);
+
        udata.updated_cb(&info, udata.data);
 }
 
@@ -257,6 +272,30 @@ static int battery_get_current_state(
        }
        info.current_average = val;
 
+       path = BATTERY_ROOT_PATH"/battery/voltage_now";
+       ret = sys_get_int(path, &val);
+       if (ret < 0) {
+               _E("Failed to get value of (%s, %d)", path, ret);
+               return ret;
+       }
+       info.voltage_now = val;
+
+       path = BATTERY_ROOT_PATH"/battery/voltage_avg";
+       ret = sys_get_int(path, &val);
+       if (ret < 0) {
+               _E("Failed to get value of (%s, %d)", path, ret);
+               return ret;
+       }
+       info.voltage_average = val;
+
+       path = BATTERY_ROOT_PATH"/battery/temp";
+       ret = sys_get_int(path, &val);
+       if (ret < 0) {
+               _E("Failed to get value of (%s, %d)", path, ret);
+               return ret;
+       }
+       info.temperature = val;
+
        updated_cb(&info, data);
 
        return 0;