mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-01 10:18:17 +02:00
up-device: a filter to ignore the unknown status from the devices
Ignore all the unknown events from the devices.
This commit is contained in:
parent
ab50a2bb3e
commit
76e2b9e571
1 changed files with 16 additions and 0 deletions
|
|
@ -183,6 +183,19 @@ ensure_history (UpDevice *device)
|
|||
up_history_set_id (priv->history, id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
up_device_history_filter (UpDevice *device, UpHistory *history)
|
||||
{
|
||||
UpExportedDevice *skeleton = UP_EXPORTED_DEVICE (device);
|
||||
|
||||
if (up_exported_device_get_state (skeleton) == UP_DEVICE_STATE_UNKNOWN) {
|
||||
g_debug ("device %s has unknown state, not saving history",
|
||||
up_exported_device_get_native_path (skeleton));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_history (UpDevice *device)
|
||||
{
|
||||
|
|
@ -191,6 +204,9 @@ update_history (UpDevice *device)
|
|||
|
||||
ensure_history (device);
|
||||
|
||||
if (!up_device_history_filter (device, priv->history))
|
||||
return;
|
||||
|
||||
/* save new history */
|
||||
up_history_set_state (priv->history, up_exported_device_get_state (skeleton));
|
||||
up_history_set_charge_data (priv->history, up_exported_device_get_percentage (skeleton));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue