Search
SailfishOS Open Build Service
>
Projects
>
home:wdehoog
>
statefs-providers
> provider_power_udev.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File provider_power_udev.patch of Package statefs-providers
1. On bacon a pc is detected as a charger but a normal charger is not. 2. On bacon battery full is never triggered. State remains "charging". Use the capacity value to detect it. --- src/power_udev/provider_power_udev.cpp 2017-01-07 18:10:10.974137713 +0000 +++ src/power_udev/provider_power_udev.cpp 2017-01-07 23:09:38.894544657 +0000 @@ -442,7 +442,12 @@ ChargerInfo(udevpp::Device const &dev) : type(charger_type(attr(dev.attr("type")))) , state([&dev]() { + // on bacon online=0 when connected to a charger but present=1 + // when connected to a pc both present and online are 1 + auto present = attr(dev.attr("present"), -13); auto v = attr(dev.attr("online"), -13); + if(present) + return ChargerState::Online; return (v == 0 ? ChargerState::Offline : (v == -13 @@ -830,6 +835,26 @@ void ChargingInfo::calculate(BatteryInfo &battery, bool is_recalculate) { + // for bacon status remains Charging so try another way to detect Full. + // when we are online and have capacity == 100 + // we can not test for battery.status.changed() since it does not work (for bacon) + if(is_online.last()) { + // when connected to a charger detect Full + if(battery.capacity.last() == 100 && state.last() != ChargingState::Idle) { + state.set(ChargingState::Idle); + battery.on_charging_changed(state.last()); + return; + } + } else { + // when Full detect Discharging + //if(battery.capacity.last() == 100 && state.last() != ChargingState::Discharging) { + if(state.last() != ChargingState::Discharging) { + state.set(ChargingState::Discharging); + battery.on_charging_changed(state.last()); + return; + } + } + if (battery.status.changed() || is_recalculate) { auto s = battery.status.last(); log.debug("Battery status changed: ", s);