healthd: Read battery manufacturing and first use dates as int64s.
Bug: 403653167
Test: builds
Change-Id: Ib3fb506059425824d866901b2c1ebe9f970bdf3a
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index b0a14bb..8b8d6e5 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -342,9 +342,10 @@
return value;
}
-static int getIntField(const String8& path) {
+template <typename T = int>
+static T getIntField(const String8& path) {
std::string buf;
- int value = 0;
+ T value = 0;
if (readFromFile(path, &buf) > 0)
android::base::ParseInt(buf, &value);
@@ -416,11 +417,11 @@
if (!mHealthdConfig->batteryManufacturingDatePath.empty())
ensureBatteryHealthData(mHealthInfo.get())->batteryManufacturingDateSeconds =
- getIntField(mHealthdConfig->batteryManufacturingDatePath);
+ getIntField<int64_t>(mHealthdConfig->batteryManufacturingDatePath);
if (!mHealthdConfig->batteryFirstUsageDatePath.empty())
ensureBatteryHealthData(mHealthInfo.get())->batteryFirstUsageSeconds =
- getIntField(mHealthdConfig->batteryFirstUsageDatePath);
+ getIntField<int64_t>(mHealthdConfig->batteryFirstUsageDatePath);
mHealthInfo->batteryTemperatureTenthsCelsius =
mBatteryFixedTemperature ? mBatteryFixedTemperature