Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
[power-udev] Handle high voltage dedicated chargers. Fixes JB#39319
Browse files Browse the repository at this point in the history
When high voltage charger is connected, initially kernel reports
USB_DCP and then switches to USB_HVDCP. As the high voltage
dedicated charger profile types are not known to statefs and
the value of OnBattery property is derived from the charger type,
the observers of statefs properties see what looks like a charger
connect followed almost immediately by charger disconnect.

When kernel reports either USB_HVDCP or USB_HVDCP_3 charger type,
expose it as "hvdcp" charger type from statefs udev provider.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Nov 14, 2017
1 parent d2e5319 commit 59f4ac2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/power_udev/provider_power_udev.cpp
Expand Up @@ -263,13 +263,13 @@ static char const * get_chg_state_name(ChargingState v)
}

enum class ChargerType {
First_ = 0, Absent = First_, DCP, CDP, USB, Mains, Unknown, Last_ = Unknown
First_ = 0, Absent = First_, DCP, HVDCP, CDP, USB, Mains, Unknown, Last_ = Unknown
};

static char const * get_chg_type_name(ChargerType t)
{
static char const * names[] = {
"", "dcp", "cdp", "usb", "dcp", "unknown"
"", "dcp", "hvdcp", "cdp", "usb", "dcp", "unknown"
};
static_assert(sizeof(names)/sizeof(names[0])
== cor::enum_size<ChargerType>()
Expand All @@ -279,6 +279,8 @@ static char const * get_chg_type_name(ChargerType t)

static const std::map<std::string, ChargerType> charger_types = {
{"USB_DCP", ChargerType::DCP},
{"USB_HVDCP", ChargerType::HVDCP},
{"USB_HVDCP_3", ChargerType::HVDCP},
{"USB", ChargerType::USB},
{"Mains", ChargerType::Mains},
{"CDP", ChargerType::CDP},
Expand Down Expand Up @@ -570,7 +572,7 @@ class BatteryNs : public statefs::Namespace
*
* - Current (uA) - battery current (positive - charging)
*
* - ChargerType (string) [usb, dcp, cdp, unknown] - charger type
* - ChargerType (string) [usb, dcp, hvdcp, cdp, unknown] - charger type
* ("" - if absent)
*
* - Level - (string) [unknown, normal, low, empty] - battery level
Expand Down

0 comments on commit 59f4ac2

Please sign in to comment.