StateFS replacement for stats

With StateFS deprecation, would be great to know how the same statistics can be gathered in the system. Interest stems from collectd which is using stateFS for several readouts. As collectd is C daemon, I am looking for something that can be read out from pure C and available for regular users, not root.

Readouts I am interested in:

  • /run/state/namespaces/Battery/

    • ChargePercentage, Capacity, Current, Energy, Power, Temperature, TimeUntilFull, TimeUntilLow, Voltage
  • /run/state/namespaces/Bluetooth/

    • Connected, Enabled, Visible
  • /run/state/namespaces/Cellular/

    • Technology, SignalStrength
  • /run/state/namespaces/Internet/

    • NetworkState, NetworkType, SignalStrength

Whether it is possible to use StateFS on 3.4.0 and later releases, I don’t know.

3 Likes

I’ve been using those via ContextProperty (in C++). I have no idea, if that is still supported though: https://nheko.im/nheko-reborn/konheko/-/blob/master/src/sync.cpp#L22

1 Like

i am the developer of batterybuddy, and i tried to use statefs only to found out that the ‘files’ there don’t update when their contents get updated. that is, i can’t monitor the file for modification, but i have to constantly re-read the file in order to spot the changes. i guess this behavior is inherited from /proc and is ultimately caused by crappy aosp implementation. if it can’t be relied upon - thanks sony and qualcomm i guess - it should be removed, or fixed, or replaced with something that works… i’m not saying sony should be ditched, but a competitor would be nice. they won’t care anyway.

another piece of art is flashlight; on xa2 it involves gstreamer, which means it’s requesting a 1x1 px video with the led on or something. back on jolla1 it was simply a file in /proc iirc… with cumbersome platform there is only so much the sailors can do…

1 Like

For all the drawbacks in terms of not notifying the change, stateFS allows to use plain C daemons to query system state. That’s exactly what collectd has been doing for years. In this respect, Qt & C++ would not be desirable “solutions”, unfortunately.