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

Commit

Permalink
[power-udev] Expect POWER_SUPPLY_REAL_TYPE udev property. JB#38667
Browse files Browse the repository at this point in the history
On devices like Xperia 10 statefs fails to report charger type which
then leads to issues situations where one needs to differentiate
between for example wall chargers and other kinds of chargers. This
happens due to kernel/udev reporting two device type properties:
  POWER_SUPPLY_TYPE=USB_PD
  POWER_SUPPLY_REAL_TYPE=USB_HVDCP
of which REAL_TYPE has the content statefs expects to see in TYPE.

When POWER_SUPPLY_REAL_TYPE property is defined, use it instead of
POWER_SUPPLY_TYPE.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Aug 23, 2019
1 parent c5205f3 commit fac9bcc
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 @@ -4,7 +4,9 @@
*
* Uses udev as source
*
* @copyright (C) 2015 Jolla Ltd.
* Copyright (C) 2015-2019 Jolla Ltd.
* Copyright (c) 2019 Open Mobile Platform LLC.
*
* @par License: LGPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*/

Expand Down Expand Up @@ -447,7 +449,7 @@ class BatteryInfo
struct ChargerInfo
{
ChargerInfo(udevpp::Device const &dev)
: type(charger_type(attr(dev.attr("type"))))
: type(charger_type(attr(dev.attr("real_type") ?: dev.attr("type"))))
, state([&dev]() {
auto v = attr(dev.attr("online"), -13);
return (v == 0
Expand Down Expand Up @@ -1306,7 +1308,7 @@ void Monitor::after_enumeration()

void Monitor::on_device(udevpp::Device &&dev)
{
auto t = attr(dev.attr("type"));
auto t = attr(dev.attr("real_type") ?: dev.attr("type"));
if (t == "Battery") {
// TODO there can be several batteries including also backup battery
battery_.update(std::move(dev));
Expand Down

0 comments on commit fac9bcc

Please sign in to comment.