Fix condition of battery charging noti 62/229462/5
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 1 Apr 2020 06:20:38 +0000 (15:20 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 3 Apr 2020 01:49:45 +0000 (01:49 +0000)
On battery changed, always call power_supply_noti depends on
changed charge_status. Repeated same power_supply_noti() call will
be ignored by power_supply_noti() itself. As a reusult, it works
only for the battery_status changing.

Change-Id: Ic49979cafe1f33a36f91f4831edcdcbb8f5ed839
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/battery/power-supply.c

index 19324e1..52d61e5 100644 (file)
@@ -1010,13 +1010,16 @@ static void battery_changed(struct battery_info *info, void *data)
                return;
 
        ret = booting_done(NULL);
-       if (ret && ((old_battery.online != battery.online) ||
-               (battery.online >= CHARGER_WIRELESS_TYPE_BT && old_battery.charge_status == CHARGE_STATUS_DISCHARGING))) {
-               if (battery.online > POWER_SUPPLY_TYPE_BATTERY && battery.charge_now == CHARGER_CHARGING)
+       if (ret) {
+               /* If the same notification is requested repeatedly, it is ignored by power_supply_noti().
+                * A notification will be triggered only when charge_status changes between
+                * CHARGE_STATUS_CHARGING/FULL <-> CHARGE_STATUS_DISCHARGING. */
+               if (battery.charge_status == CHARGE_STATUS_CHARGING || battery.charge_status == CHARGE_STATUS_FULL)
                        power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_ON);
-               else
+               else if (battery.charge_status == CHARGE_STATUS_DISCHARGING)
                        power_supply_noti(DEVICE_NOTI_BATT_CHARGE, DEVICE_NOTI_OFF);
        }
+
        if (ret == 0) {
                battery.health = HEALTH_GOOD;
                battery.present = PRESENT_NORMAL;