idevice: Prefer the user-chosen name when available

Use the device name as model name when the user-chosen device name is available.
This matches what the Bluez backend does.
This commit is contained in:
Kai Uwe Broulik 2022-11-16 14:06:01 +01:00 committed by Bastien Nocera
parent 38a52894a3
commit a795750a2e

View file

@ -219,6 +219,7 @@ up_device_idevice_refresh (UpDevice *device, UpRefreshReason reason)
idevice_t dev = idevice->priv->dev;
lockdownd_client_t client = NULL;
lockdownd_error_t lerr;
char *name = NULL;
plist_t dict, node;
guint64 percentage;
guint8 charging, has_battery;
@ -243,6 +244,15 @@ up_device_idevice_refresh (UpDevice *device, UpRefreshReason reason)
goto out;
}
if (lockdownd_get_device_name (client, &name) == LOCKDOWN_E_SUCCESS) {
/* Prefer the user-chosen name for the device when available */
g_object_set (device,
"vendor", NULL,
"model", name,
NULL);
free (name);
}
if (lockdownd_get_value (client, "com.apple.mobile.battery", NULL, &dict) != LOCKDOWN_E_SUCCESS)
goto out;