Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get battery data from statefs #237

Merged
merged 5 commits into from Jan 27, 2015
Merged

Get battery data from statefs #237

merged 5 commits into from Jan 27, 2015

Conversation

spiiroin
Copy link
Contributor

No description provided.

Add helpers for getting state names and use them in diagnostic logging.
Performs similar task as existing battery_bme and battery_upower plugins,
but gets the battery data from files maintained by the statefs service.

Checks presense of required propery files in /run/state/namespaces/Battery
directory on mce startup. If files are not present, or become not available
later on due to stopping and/or restarting of statefs service, periodic
checks are made to detect when they come available again.

While the files available, the battery level, status and charging activity
state changes are tracked and pushed to datapipes in the form existing mce
logic is expecting.

[mce] Add plugin for tracking battery state via statefs. Contributes to JB#6273
By default load statefs battery plugin instead of the upower one.

[mce] Get battery data from statefs. Fixes JB#6273
It is more or less expected that end of notification can occur later
than expected and there is no harm in ending notification state even
though one is not even started. Hence there is no need to spam the
journal with these messages on default logging verbosity.
sfsbat_state_t state;
} state_lut[] =
{
{ "charging", STATEFS_BATTERY_STATE_CHARGING },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend you to add also "unknown" state tracking, adding it instead of separate IsValid (or similar) property

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of built into startup defaults, but handling it explicitly is clearer (and works if battery should for some reason go to unknown state after initial probing too). Will fix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand you are right: maybe "unknown" should be anything except known values. Also empty string is suitable for this state.

The logic assumed that battery is in unknown state until statefs reports
transition to [charging, discharging, full, empty] is seen. However transitions
to unknown state are ignored and the previous state is kept.

Add "unknown" to set of expected Battery.State values.

Treat empty string as an alias for "unknown".

Unrecognized string values are treated similarly as "unknown", but a
warning is emitted to journal.
spiiroin added a commit that referenced this pull request Jan 27, 2015
@spiiroin spiiroin merged commit 5caed8e into nemomobile:master Jan 27, 2015
@spiiroin spiiroin deleted the jb6273_battery_statefs branch January 27, 2015 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants