summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2011-07-19 16:14:20 +0100
committerRichard Hughes <richard@hughsie.com>2011-07-19 16:14:20 +0100
commitcb37dcc2e86ec9b244ab732004f2f020f130aa81 (patch)
tree4b784affd53dcc0964ba8c7e18254926d602d4d1
parentb19fca96371d65d3bb1069385ede8b66de31aefa (diff)
Hardcode wacom battery devices as not power-supply devices
We'll switch to a kernel property when the power_supply interface is fixed.
-rw-r--r--src/linux/up-device-supply.c34
1 files 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
@@ -63,6 +63,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:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
@@ -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");