Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 3217c5c7 authored by Michael Scott's avatar Michael Scott
Browse files

batterymonitor: simplify readFromFile and use std::string buffers



In readFromFile() when a newline is not found in the data, we reset
the initial character of the buffer to \0, but leave the count as is
(something >0 in this case).

Later in getBooleanField() we could erroneously treat a response as
"true" because count would be >0 and the initial value of buf would
be != '0' (set to \0 in this case).

To fixup error paths such as this, we can simplify readFromFile
by using android::base functions: ReadFromFileString() and Trim().

NOTES:
- Converted char * buffers used with readFromFile to std::string
- Removed unused variable btech from BatteryMonitor::update

Testing Done:
- Build healthd and recovery for angler device
- Confirm that known values are being read correctly from kernel
  sysfs.

Change-Id: I238bbff097543767f352aa084bf0acbc1324baca
Signed-off-by: default avatarMichael Scott <michael.scott@linaro.org>
parent 863d8e11
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment