1

Long story short I was installing custom ROMs to my Android device and one thing that stays in place regardless of ROM I use is a wrong battery stats monitoring. The device always behaves like it's being charged, although it's not.

I've checked the /sys/class/power_supply/battery and voila - there's no battery, only /sys/class/power_supply/usb. According to some docs I've found that will make the system think it's connected to an external power source.

The question is what is responsible for creating this battery file - is it a kernel, or a ROM (i.e. LineageOS, Resurrection Remix etc).


[UPD:] In the document I've provided they write about /sys/devices/power_supply, not /sys/class/, although here the /sys/class/power_supply/*/ is mentioned as a Kernel interface. Should I assume that it's a Kernel issue then?

It's interesting though, that the stock ROM does show battery stats correctly, although nothing was added to /sys/class/ and TWRP recovery I'm using shows battery charge as -1%.

  • Did you check ls -d /sys/devices/*/power_supply/battery or ls -d /sys/devices/*/*/power_supply/battery or ls /sys/class/power_supply/battery? Both ROM and kernel are involved in hardware handling. There must be some binary blob in /vendor acting as HAL which interacts with kernel, which ultimately deals with hardware. Mostly custom ROMs keep on including the same blobs in their ROMs extracted by someone. Do you face same issue with your stock ROM? – Irfan Latif Jul 9 at 14:25
  • @IrfanLatif I've updated the question. Will go and read 'em manuals a bit more, thanks for showing the direction. And no, stock ROM was fine. – Usurer Jul 9 at 14:31
  • So you have checked and there is no /sys/class/power_supply/battery/status? If it exists cat it. – Irfan Latif Jul 9 at 14:57
  • Yeah, there's even no /battery there - just /usb. – Usurer Jul 9 at 15:07
  • And there is no pgrep -a hardware.health either? – Irfan Latif Jul 9 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.