summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-06-18 13:09:47 +0100
committerRichard Hughes <richard@hughsie.com>2012-06-18 13:10:08 +0100
commit23f6127327b524b51560d0bc254f18dc18294eea (patch)
tree8a973b2321901d03fec363d8bbfe666492d5c0e2
parent48edf2f1a8df125794a452034ccf9b48d9c8eead (diff)
linux: Don't allow non-power-supply devices to set the OnBattery property
Signed-off-by: Richard Hughes <richard@hughsie.com>
-rw-r--r--src/linux/up-device-supply.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index ec2514a..8201631 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -147,6 +147,7 @@ up_device_supply_get_on_battery (UpDevice *device, gboolean *on_battery)
UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
UpDeviceKind type;
UpDeviceState state;
+ gboolean is_power_supply;
gboolean is_present;
g_return_val_if_fail (UP_IS_DEVICE_SUPPLY (supply), FALSE);
@@ -156,8 +157,11 @@ up_device_supply_get_on_battery (UpDevice *device, gboolean *on_battery)
"type", &type,
"state", &state,
"is-present", &is_present,
+ "power-supply", &is_power_supply,
NULL);
+ if (!is_power_supply)
+ return FALSE;
if (type != UP_DEVICE_KIND_BATTERY)
return FALSE;
if (state == UP_DEVICE_STATE_UNKNOWN)