diff options
author | Richard Hughes <richard@hughsie.com> | 2009-08-06 11:18:10 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2009-08-06 11:18:10 +0100 |
commit | 40e554865d3a298d5a31a26bf05680557d388570 (patch) | |
tree | 5aa91284746a4f9c81523a6cf9411c43eef116ba | |
parent | ca12319d1fa1a720e00954602155311cb7fbc433 (diff) | |
parent | 260cf76f1d86bae79e56f4859aa983f17e01300f (diff) |
Merge branch 'master' into not-just-gudev2
-rw-r--r-- | src/linux/dkp-device-supply.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/linux/dkp-device-supply.c b/src/linux/dkp-device-supply.c index ed4cdc4..1cc4f0d 100644 --- a/src/linux/dkp-device-supply.c +++ b/src/linux/dkp-device-supply.c @@ -50,6 +50,7 @@ struct DkpDeviceSupplyPrivate gdouble energy_old; GTimeVal energy_old_timespec; guint unknown_retries; + gboolean enable_poll; }; static void dkp_device_supply_class_init (DkpDeviceSupplyClass *klass); @@ -459,6 +460,10 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply) state = DKP_DEVICE_STATE_UNKNOWN; } + /* only disable the polling if the kernel tells us we're fully charged, + not if we've guessed the state to be fully charged */ + supply->priv->enable_poll = (state != DKP_DEVICE_STATE_FULLY_CHARGED); + /* reset unknown counter */ if (state != DKP_DEVICE_STATE_UNKNOWN) { egg_debug ("resetting unknown timeout after %i retries", supply->priv->unknown_retries); @@ -660,8 +665,8 @@ dkp_device_supply_setup_poll (DkpDevice *device) g_object_get (device, "state", &state, NULL); - /* if it's fully charged, don't poll at all */ - if (state == DKP_DEVICE_STATE_FULLY_CHARGED) + /* don't setup the poll only if we're sure */ + if (!supply->priv->enable_poll) goto out; /* if it's unknown, poll faster than we would normally */ @@ -731,6 +736,7 @@ dkp_device_supply_init (DkpDeviceSupply *supply) supply->priv = DKP_DEVICE_SUPPLY_GET_PRIVATE (supply); supply->priv->unknown_retries = 0; supply->priv->poll_timer_id = 0; + supply->priv->enable_poll = TRUE; } /** |