battery: convert ONLINE property value to standard one 56/270456/1 submit/tizen/20220208.075544
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 27 Jan 2022 06:02:15 +0000 (15:02 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 3 Feb 2022 05:20:22 +0000 (14:20 +0900)
Change-Id: I0a98cd552865437cf4b45316e256d75375aeaaa4
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
hw/battery/battery.c

index 3a3d962..70e9812 100644 (file)
@@ -87,6 +87,7 @@ static void uevent_delivered(struct udev_device *dev)
        struct battery_info info;
        char *val;
        int ret;
+       int temp;
 
        _I("POWER_SUPPLY uevent is delivered");
 
@@ -113,7 +114,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)