summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/linux/up-device-supply.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 0b8a0eb..6edf420 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -450,8 +450,12 @@ up_device_supply_get_state (const gchar *native_path)
UpDeviceState state;
gchar *status;
- status = g_strstrip (sysfs_get_string (native_path, "status"));
- if (g_ascii_strcasecmp (status, "charging") == 0)
+ status = up_device_supply_get_string (native_path, "status");
+ if (status == NULL ||
+ g_ascii_strcasecmp (status, "unknown") == 0 ||
+ *status == '\0') {
+ state = UP_DEVICE_STATE_UNKNOWN;
+ } else if (g_ascii_strcasecmp (status, "charging") == 0)
state = UP_DEVICE_STATE_CHARGING;
else if (g_ascii_strcasecmp (status, "discharging") == 0)
state = UP_DEVICE_STATE_DISCHARGING;
@@ -459,9 +463,6 @@ up_device_supply_get_state (const gchar *native_path)
state = UP_DEVICE_STATE_FULLY_CHARGED;
else if (g_ascii_strcasecmp (status, "empty") == 0)
state = UP_DEVICE_STATE_EMPTY;
- else if (g_ascii_strcasecmp (status, "unknown") == 0 ||
- *status == '\0')
- state = UP_DEVICE_STATE_UNKNOWN;
else if (g_ascii_strcasecmp (status, "not charging") == 0)
state = UP_DEVICE_STATE_PENDING_CHARGE;
else {