summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKate Hsuan <hpa@redhat.com>2024-02-26 17:10:26 +0800
committerKate Hsuan <hpa@redhat.com>2024-03-05 16:27:16 +0800
commit76e2b9e5719978cc2ffb92fcd422748776c17874 (patch)
treee6e2c0a8503857b62652d12cc5aafbb589a9e2a3
parentab50a2bb3ec87c4ac01351368dc09df6fa369866 (diff)
up-device: a filter to ignore the unknown status from the devices
Ignore all the unknown events from the devices.
-rw-r--r--src/up-device.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/up-device.c b/src/up-device.c
index 9ee01db..e4b0b38 100644
--- a/src/up-device.c
+++ b/src/up-device.c
@@ -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));