From cb37dcc2e86ec9b244ab732004f2f020f130aa81 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 19 Jul 2011 16:14:20 +0100 Subject: Hardcode wacom battery devices as not power-supply devices We'll switch to a kernel property when the power_supply interface is fixed. --- src/linux/up-device-supply.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index 600fc27..9b29713 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -62,6 +62,30 @@ G_DEFINE_TYPE (UpDeviceSupply, up_device_supply, UP_TYPE_DEVICE) static gboolean up_device_supply_refresh (UpDevice *device); +/** + * up_device_supply_is_power_supply: + * + * Blacklist wacom tablets until we get a sysfs interface that + * doesn't suck... + **/ +static gboolean +up_device_supply_is_power_supply (UpDeviceSupply *supply) +{ + gchar *native_path; + gboolean is_power_supply = TRUE; + + g_object_get (supply, + "native-path", &native_path, + NULL); + if (g_strstr_len (native_path, -1, "wacom_battery") != NULL || + g_strstr_len (native_path, -1, "wacom_ac") != NULL) { + g_debug ("found a wacom tablet"); + is_power_supply = FALSE; + } + g_free (native_path); + return is_power_supply; +} + /** * up_device_supply_refresh_line_power: * @@ -74,8 +98,10 @@ up_device_supply_refresh_line_power (UpDeviceSupply *supply) GUdevDevice *native; const gchar *native_path; - /* force true */ - g_object_set (device, "power-supply", TRUE, NULL); + /* is providing power to computer? */ + g_object_set (device, + "power-supply", up_device_supply_is_power_supply (supply), + NULL); /* get new AC value */ native = G_UDEV_DEVICE (up_device_get_native (device)); @@ -447,7 +473,9 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply) up_device_supply_units_changed (supply, native_path)) { /* when we add via sysfs power_supply class then we know this is true */ - g_object_set (device, "power-supply", TRUE, NULL); + g_object_set (device, + "power-supply", up_device_supply_is_power_supply (supply), + NULL); /* the ACPI spec is bad at defining battery type constants */ technology_native = up_device_supply_get_string (native_path, "technology"); -- cgit v1.2.3