battery: fix condition of update_online() 71/269571/1
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 18 Jan 2022 09:15:06 +0000 (18:15 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 18 Jan 2022 09:15:06 +0000 (18:15 +0900)
Initialize online_status by -1 so that the update_online() shall process
properly even when the device has turned on with charger disconnected.

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

index e886782..cddbe9a 100644 (file)
@@ -94,7 +94,7 @@ static const struct uevent_handler uh = {
 static struct battery_status battery;
 struct battery_status old_battery;
 static int noti_id;
-static int online_status;
+static int online_status = -1;
 static int abnormal_health_popup_timer;
 static bool launching_health_popup;
 
@@ -571,7 +571,7 @@ static bool update_online(void)
        }
 
        if (battery.online > POWER_SUPPLY_TYPE_BATTERY &&
-           online_status == VCONFKEY_SYSMAN_CHARGER_DISCONNECTED) {
+           online_status != VCONFKEY_SYSMAN_CHARGER_CONNECTED) {
                online_status = VCONFKEY_SYSMAN_CHARGER_CONNECTED;
                extcon_update_count(EXTCON_TA, 1);
                check_power_supply(online_status);
@@ -581,7 +581,7 @@ static bool update_online(void)
                        charger_state_send_system_event(battery.charge_status);
                broadcast = true;
        } else if (battery.online <= POWER_SUPPLY_TYPE_BATTERY &&
-           online_status == VCONFKEY_SYSMAN_CHARGER_CONNECTED) {
+           online_status != VCONFKEY_SYSMAN_CHARGER_DISCONNECTED) {
                online_status = VCONFKEY_SYSMAN_CHARGER_DISCONNECTED;
                check_power_supply(online_status);
                if (old_battery.charge_status != battery.charge_status)