summaryrefslogtreecommitdiff
path: root/healthd
diff options
context:
space:
mode:
authorTomasz Wasilczyk <twasilczyk@google.com>2023-09-12 15:26:15 +0000
committerTomasz Wasilczyk <twasilczyk@google.com>2023-09-20 15:11:54 +0000
commit2b1a0599c4530c34b57ba109917904451b55214e (patch)
tree1467c5c4f43c6a013498516d999cf4847b98c66b /healthd
parentd741c23288096e47928e64a2a27ed764487fe694 (diff)
downloadcore-2b1a0599c4530c34b57ba109917904451b55214e.tar.gz
Don't depend on String8 cast to C string
Bug: 295394788 Test: m checkbuild Change-Id: I5b86ae56250d409a23ab3f2bc72b725bcf6ab23e
Diffstat (limited to 'healthd')
-rw-r--r--healthd/BatteryMonitor.cpp56
-rw-r--r--healthd/BatteryMonitor_v1.cpp38
2 files changed, 47 insertions, 47 deletions
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index e4cf582fb..0c976322d 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -432,7 +432,7 @@ void BatteryMonitor::updateValues(void) {
}
if (readFromFile(mHealthdConfig->batteryTechnologyPath, &buf) > 0)
- mHealthInfo->batteryTechnology = String8(buf.c_str());
+ mHealthInfo->batteryTechnology = buf;
if (readFromFile(mHealthdConfig->chargingPolicyPath, &buf) > 0)
mHealthInfo->chargingPolicy = getBatteryChargingPolicy(buf.c_str());
@@ -786,39 +786,35 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryStatusPath = path;
}
if (mHealthdConfig->batteryHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryHealthPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryHealthPath = path;
}
if (mHealthdConfig->batteryPresentPath.empty()) {
path.clear();
path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryPresentPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryPresentPath = path;
}
if (mHealthdConfig->batteryCapacityPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryCapacityPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryCapacityPath = path;
}
if (mHealthdConfig->batteryVoltagePath.empty()) {
path.clear();
path.appendFormat("%s/%s/voltage_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryVoltagePath = path;
}
}
@@ -827,7 +823,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/charge_full",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargePath = path;
}
@@ -835,7 +831,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/current_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentNowPath = path;
}
@@ -843,27 +839,29 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/cycle_count",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCycleCountPath = path;
}
if (mHealthdConfig->batteryCapacityLevelPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity_level", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryCapacityLevelPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryCapacityLevelPath = path;
+ }
}
if (mHealthdConfig->batteryChargeTimeToFullNowPath.empty()) {
path.clear();
path.appendFormat("%s/%s/time_to_full_now", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeTimeToFullNowPath = path;
}
if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
}
@@ -871,7 +869,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/current_avg",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentAvgPath = path;
}
@@ -879,7 +877,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/charge_counter",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeCounterPath = path;
}
@@ -887,7 +885,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryTemperaturePath = path;
}
}
@@ -896,19 +894,19 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/technology",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryTechnologyPath = path;
}
if (mHealthdConfig->batteryStateOfHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/state_of_health", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryStateOfHealthPath = path;
} else {
path.clear();
path.appendFormat("%s/%s/health_index", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryStateOfHealthPath = path;
}
}
@@ -916,32 +914,36 @@ void BatteryMonitor::init(struct healthd_config *hc) {
if (mHealthdConfig->batteryHealthStatusPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health_status", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryHealthStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryHealthStatusPath = path;
+ }
}
if (mHealthdConfig->batteryManufacturingDatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/manufacturing_date", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryManufacturingDatePath = path;
}
if (mHealthdConfig->batteryFirstUsageDatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/first_usage_date", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryFirstUsageDatePath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryFirstUsageDatePath = path;
+ }
}
if (mHealthdConfig->chargingStatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/charging_state", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->chargingStatePath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->chargingStatePath = path;
}
if (mHealthdConfig->chargingPolicyPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charging_policy", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->chargingPolicyPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->chargingPolicyPath = path;
}
break;
diff --git a/healthd/BatteryMonitor_v1.cpp b/healthd/BatteryMonitor_v1.cpp
index 686c338cc..2e0cfc971 100644
--- a/healthd/BatteryMonitor_v1.cpp
+++ b/healthd/BatteryMonitor_v1.cpp
@@ -352,7 +352,7 @@ void BatteryMonitor::updateValues(void) {
mHealthInfo->batteryHealth = getBatteryHealth(buf.c_str());
if (readFromFile(mHealthdConfig->batteryTechnologyPath, &buf) > 0)
- mHealthInfo->batteryTechnology = String8(buf.c_str());
+ mHealthInfo->batteryTechnology = buf;
double MaxPower = 0;
@@ -639,39 +639,35 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryStatusPath = path;
}
if (mHealthdConfig->batteryHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryHealthPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryHealthPath = path;
}
if (mHealthdConfig->batteryPresentPath.empty()) {
path.clear();
path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryPresentPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryPresentPath = path;
}
if (mHealthdConfig->batteryCapacityPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryCapacityPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryCapacityPath = path;
}
if (mHealthdConfig->batteryVoltagePath.empty()) {
path.clear();
path.appendFormat("%s/%s/voltage_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryVoltagePath = path;
}
}
@@ -680,7 +676,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/charge_full",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargePath = path;
}
@@ -688,7 +684,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/current_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentNowPath = path;
}
@@ -696,27 +692,29 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/cycle_count",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCycleCountPath = path;
}
if (mHealthdConfig->batteryCapacityLevelPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity_level", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryCapacityLevelPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryCapacityLevelPath = path;
+ }
}
if (mHealthdConfig->batteryChargeTimeToFullNowPath.empty()) {
path.clear();
path.appendFormat("%s/%s/time_to_full_now", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeTimeToFullNowPath = path;
}
if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
}
@@ -724,7 +722,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/current_avg",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentAvgPath = path;
}
@@ -732,7 +730,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/charge_counter",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeCounterPath = path;
}
@@ -740,7 +738,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryTemperaturePath = path;
}
}
@@ -749,7 +747,7 @@ void BatteryMonitor::init(struct healthd_config *hc) {
path.clear();
path.appendFormat("%s/%s/technology",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryTechnologyPath = path;
}