From e6d4b8cd4a26ee1ece81dee4bde4e3744259b435 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Tue, 14 Jun 2022 17:48:22 +0200 Subject: [PATCH] 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 --- src/up-daemon.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/up-daemon.c b/src/up-daemon.c index 74c6741..ee4149c 100644 --- a/src/up-daemon.c +++ b/src/up-daemon.c @@ -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; } }