daemon: Guess state for multiple batteries without AC

There is no reason to not guess the state if the device has no AC power
and there is more than one battery. Remove the corresponding constraint.

Related: #146
This commit is contained in:
Benjamin Berg 2022-06-14 17:48:22 +02:00
parent 2a1ab444e8
commit e6d4b8cd4a

View file

@ -260,26 +260,16 @@ out:
ac_online = up_daemon_get_on_ac_local (daemon, &has_ac);
if (has_ac) {
if (ac_online) {
if (percentage_total >= UP_FULLY_CHARGED_THRESHOLD)
state_total = UP_DEVICE_STATE_FULLY_CHARGED;
else
state_total = UP_DEVICE_STATE_CHARGING;
} else {
if (percentage_total < 1.0f)
state_total = UP_DEVICE_STATE_EMPTY;
else
state_total = UP_DEVICE_STATE_DISCHARGING;
}
if (has_ac && ac_online) {
if (percentage_total >= UP_FULLY_CHARGED_THRESHOLD)
state_total = UP_DEVICE_STATE_FULLY_CHARGED;
else
state_total = UP_DEVICE_STATE_CHARGING;
} else {
/* only guess when we have only one battery */
if (up_daemon_get_number_devices_of_type (daemon, UP_DEVICE_KIND_BATTERY) == 1) {
if (percentage_total < 1.0f)
state_total = UP_DEVICE_STATE_EMPTY;
else
state_total = UP_DEVICE_STATE_DISCHARGING;
}
if (percentage_total < 1.0f)
state_total = UP_DEVICE_STATE_EMPTY;
else
state_total = UP_DEVICE_STATE_DISCHARGING;
}
}