linux: Bail out when iDevice state is malformed

If there's no BatteryCurrentCapacity value, we've failed updating
the device.
This commit is contained in:
Bastien Nocera 2015-02-03 21:29:08 +01:00
parent e37fcd1db1
commit a410c26991

View file

@ -193,6 +193,10 @@ up_device_idevice_refresh (UpDevice *device)
/* get battery status */
node = plist_dict_get_item (dict, "BatteryCurrentCapacity");
if (!node) {
plist_free (dict);
goto out;
}
plist_get_uint_val (node, &percentage);
g_object_set (device, "percentage", (double) percentage, NULL);