mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-05 16:58:07 +02:00
linux: Retry to get a battery type if it's unknown
On some devices the power_supply node will show up before a related node such as "input", making it impossible to know which type of device we're attached to without waiting. Try to detect the device type again if the device type is still "battery". This fixes some Logitech devices appearing as "Battery" instead of their respective device type, such as "mouse".
This commit is contained in:
parent
057238a04d
commit
61028d84d8
1 changed files with 11 additions and 0 deletions
|
|
@ -75,6 +75,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (UpDeviceSupply, up_device_supply, UP_TYPE_DEVICE)
|
|||
static gboolean up_device_supply_refresh (UpDevice *device);
|
||||
static void up_device_supply_setup_unknown_poll (UpDevice *device,
|
||||
UpDeviceState state);
|
||||
static UpDeviceKind up_device_supply_guess_type (GUdevDevice *native,
|
||||
const char *native_path);
|
||||
|
||||
static RefreshResult
|
||||
up_device_supply_refresh_line_power (UpDeviceSupply *supply)
|
||||
|
|
@ -918,10 +920,19 @@ up_device_supply_refresh_device (UpDeviceSupply *supply,
|
|||
GUdevDevice *native;
|
||||
gdouble percentage = 0.0f;
|
||||
UpDeviceLevel level = UP_DEVICE_LEVEL_NONE;
|
||||
UpDeviceKind type;
|
||||
|
||||
native = G_UDEV_DEVICE (up_device_get_native (device));
|
||||
native_path = g_udev_device_get_sysfs_path (native);
|
||||
|
||||
/* Try getting a more precise type again */
|
||||
g_object_get (device, "type", &type, NULL);
|
||||
if (type == UP_DEVICE_KIND_BATTERY) {
|
||||
type = up_device_supply_guess_type (native, native_path);
|
||||
if (type != UP_DEVICE_KIND_BATTERY)
|
||||
g_object_set (device, "type", type, NULL);
|
||||
}
|
||||
|
||||
/* initial values */
|
||||
if (!supply->priv->has_coldplug_values) {
|
||||
gchar *model_name;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue