battery: convert ONLINE property value to standard one 59/270459/1 accepted/tizen/6.5/unified/20220215.114255 submit/tizen_6.5/20220214.083718
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 27 Jan 2022 06:02:15 +0000 (15:02 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 3 Feb 2022 05:53:27 +0000 (05:53 +0000)
Change-Id: I0a98cd552865437cf4b45316e256d75375aeaaa4
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
hw/battery/battery.c

index cfda076..844d7e9 100644 (file)
@@ -87,6 +87,7 @@ static void uevent_delivered(struct udev_device *dev)
        struct battery_info info;
        char *val;
        int ret;
+       int temp;
 
        if (!udata.updated_cb) {
                _E("POWER_SUPPLY callback is NULL");
@@ -111,7 +112,19 @@ static void uevent_delivered(struct udev_device *dev)
        val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE");
        if (!val)
                return;
-       info.online = atoi(val);
+       /*
+        * Convert the value to standard value, 0 or 1.
+        * POWER_SUPPLY_TYPE_UNKNOWN=0, -> 0(disconnected)
+        * POWER_SUPPLY_TYPE_BATTERY=1, -> 0(disconnected)
+        * POWER_SUPPLY_TYPE_UPS=2,     -> 1(connected)
+        * POWER_SUPPLY_TYPE_MAINS=3,   -> 1(connected)
+        * POWER_SUUPLY_TYPE_USB=4      -> 1(connected)
+        */
+       temp = atoi(val);
+       if (temp == 1 || temp == 0)
+               info.online = 0;
+       else
+               info.online = 1;
 
        val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_PRESENT");
        if (!val)