up-types: recognize kernel's "N/A" spelling for CHARGE_TYPE_NONE
The kernel prints POWER_SUPPLY_CHARGE_TYPE_NONE as "N/A", not "None", so up_device_charge_type_from_string() fell through to the warning path and returned UNKNOWN instead of NONE on every refresh while discharging.
This commit is contained in:
parent
f18b1a476c
commit
628283fb20
1 changed files with 5 additions and 2 deletions
|
|
@ -282,7 +282,9 @@ up_device_charge_type_to_string (UpDeviceChargeType charge_type_enum)
|
|||
* Converts a sysfs `charge_type` string to a #UpDeviceChargeType.
|
||||
* Spelling follows the kernel `POWER_SUPPLY_CHARGE_TYPE_*` strings
|
||||
* (e.g. "Trickle", "Fast", "Long Life"); matching is case-insensitive
|
||||
* and tolerates the spaces the kernel emits for "Long Life".
|
||||
* and tolerates the spaces the kernel emits for "Long Life". The
|
||||
* kernel prints `POWER_SUPPLY_CHARGE_TYPE_NONE` as "N/A", not "None",
|
||||
* so both spellings map to %UP_DEVICE_CHARGE_TYPE_NONE.
|
||||
*
|
||||
* Return value: enumerated value
|
||||
*
|
||||
|
|
@ -295,7 +297,8 @@ up_device_charge_type_from_string (const gchar *charge_type)
|
|||
return UP_DEVICE_CHARGE_TYPE_NONE;
|
||||
if (g_ascii_strcasecmp (charge_type, "unknown") == 0)
|
||||
return UP_DEVICE_CHARGE_TYPE_UNKNOWN;
|
||||
if (g_ascii_strcasecmp (charge_type, "none") == 0)
|
||||
if (g_ascii_strcasecmp (charge_type, "none") == 0 ||
|
||||
g_ascii_strcasecmp (charge_type, "n/a") == 0)
|
||||
return UP_DEVICE_CHARGE_TYPE_NONE;
|
||||
if (g_ascii_strcasecmp (charge_type, "trickle") == 0)
|
||||
return UP_DEVICE_CHARGE_TYPE_TRICKLE;
|
||||
|
|
|
|||
Loading…
Reference in a new issue