[Patch] Check whether on battery manually after a delayed refresh(DeviceKit-Power)

Pramod Dematagoda pmd.lotr.gandalf at gmail.com
Wed Oct 14 06:35:01 PDT 2009

On Wed, 2009-10-14 at 10:36 +0100, Richard Hughes wrote:
> 2009/10/14 Pramod Dematagoda <pmd.lotr.gandalf at gmail.com>:
> > There is a problem with DKP where the daemon would not be aware of being
> > on battery or not during a delayed refresh since it would seem that the
> > backend does not send the daemon a device changed signal during such an
> > action.
> >
> > I have attached the patch that fixes this problem by making the daemon
> > check whether it is on battery or not manually during a delayed refresh.
> I would rather fix the problem rather than work around it. From my analysis:
> 1. dkp_daemon_refresh_battery_devices_cb() gets called after a short delay
> 2. this calls dkp_daemon_refresh_battery_devices(), which calls
> dkp_device_refresh_internal() on each battery device
> 3. dkp_device_refresh_internal() calls the klass->refresh() method,
> which for this battery would call dkp_device_supply_refresh()
> 4. dkp_device_supply_refresh() sets the "update-time" property and
> refreshes the device.
> ...
> 5. dkp_device_perhaps_changed_cb() gets called as
> "notify::update-time" is triggered
> 6. dkp_device_perhaps_changed_cb() emits DkpDevice::Changed() and
> DkpDaemon::DeviceChanged()
> 7. dkp_daemon_device_changed_cb gets called due to the DkpDevice::Changed signal
> 8. this updates the "on-battery" and "on-low-battery" properties
> So, it looks like the problem is step 4. We need to refresh the
> device, and then set the "update-time" property, else we calculate
> "on-battery" and "on-low-battery" according to the old data, not the
> newly refreshed data.
> This looks like it also affects DkpDeviceCsr, DkpDeviceHid and
> DkpDeviceSupply, although obviously only the last will be triggered
> from the idle refresh.
> I've attached the patch I've just merged for your review, could you
> try with the latest git and tell me if this also fixes the problem
> please. Thanks.
> Richard.

I updated to the latest git and tried without my work around Richard,
but the bug shows up again and it disappears once I apply my patch, so
it would seem that the daemon still does not get notified properly after
the delayed refresh.


More information about the devkit-devel mailing list