summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Szulecki <martin.szulecki@libimobiledevice.org>2018-03-20 15:04:26 +0100
committerBastien Nocera <hadess@hadess.net>2018-03-20 15:28:36 +0100
commit598fdbc5e00573d1b56d4107798f82bd615842b3 (patch)
tree56c673b41bf48cf82dbfae45962fc2f2df9b2e7f
parent9357aa60e7773d997e6208c9b3cab09adc166e38 (diff)
downloadupower-598fdbc5e00573d1b56d4107798f82bd615842b3.tar.gz
linux: Check "HasBattery" key for newer iOS versions
This adds an extra check to query if the iOS device has a battery at all before actually trying to retrieve the battery status. Should still work for older iOS versions which do not provide this key. https://bugzilla.freedesktop.org/show_bug.cgi?id=105625
-rw-r--r--src/linux/up-device-idevice.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/linux/up-device-idevice.c b/src/linux/up-device-idevice.c
index a583881..0c404cc 100644
--- a/src/linux/up-device-idevice.c
+++ b/src/linux/up-device-idevice.c
@@ -269,7 +269,7 @@ up_device_idevice_refresh (UpDevice *device)
lockdownd_client_t client = NULL;
plist_t dict, node;
guint64 percentage;
- guint8 charging;
+ guint8 charging, has_battery;
UpDeviceState state;
gboolean retval = FALSE;
@@ -284,6 +284,15 @@ up_device_idevice_refresh (UpDevice *device)
if (lockdownd_get_value (client, "com.apple.mobile.battery", NULL, &dict) != LOCKDOWN_E_SUCCESS)
goto out;
+ node = plist_dict_get_item (dict, "HasBattery");
+ if (node) {
+ plist_get_bool_val (node, &has_battery);
+ if (!has_battery) {
+ plist_free(dict);
+ goto out;
+ }
+ }
+
/* get battery status */
node = plist_dict_get_item (dict, "BatteryCurrentCapacity");
if (!node) {