[Patch] Check whether on battery manually after a delayed refresh(DeviceKit-Power)
hughsient at gmail.com
Wed Oct 14 02:36:50 PDT 2009
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
> 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
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
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2929 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/devkit-devel/attachments/20091014/72134e47/attachment.bin
More information about the devkit-devel