diff options
author | Benjamin Berg <bberg@redhat.com> | 2022-06-14 17:48:22 +0200 |
---|---|---|
committer | Benjamin Berg <bberg@redhat.com> | 2022-06-14 17:50:54 +0200 |
commit | e6d4b8cd4a26ee1ece81dee4bde4e3744259b435 (patch) | |
tree | 0b873fc3321cecb78b06c1765f5bb9a95833b04d | |
parent | 2a1ab444e80c034f0efb0a2dcfe8aa879507fb48 (diff) | |
download | upower-e6d4b8cd4a26ee1ece81dee4bde4e3744259b435.tar.gz |
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
-rw-r--r-- | src/up-daemon.c | 28 |
1 files 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; } } |