linux: Refresh for 5 seconds after plug/unplug on MacBooks

Pull the 2 previous changes together to refresh the battery status for a
couple of seconds after receiving an event on the power line. This fixes
charge status being inaccurate for up to 120 seconds (the normal poll
timeout on MacBooks).

https://gitlab.freedesktop.org/upower/upower/issues/56
This commit is contained in:
Bastien Nocera 2018-06-19 13:44:24 +02:00
parent 6ab61bac9d
commit 7188cc0417

View file

@ -38,6 +38,7 @@
#include "up-types.h"
#include "up-constants.h"
#include "up-device-supply.h"
#include "up-backend-linux-private.h"
#define UP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */
@ -1146,8 +1147,8 @@ up_device_supply_setup_unknown_poll (UpDevice *device,
return;
/* if it's unknown, poll faster than we would normally */
if (state == UP_DEVICE_STATE_UNKNOWN &&
supply->priv->unknown_retries < UP_DAEMON_UNKNOWN_RETRIES) {
if (supply->priv->unknown_retries < UP_DAEMON_UNKNOWN_RETRIES &&
(state == UP_DEVICE_STATE_UNKNOWN || up_backend_needs_poll_after_uevent ())) {
gint64 now;
supply->priv->poll_timer_id =
g_timeout_add_seconds (UP_DAEMON_UNKNOWN_TIMEOUT,