Migrate from android::String isEmpty to empty
This empty method is different from the old one - it aligns with
std::string definition.
Bug: 295394788
Test: make checkbuild
Change-Id: Id6baed8cde01a75a8839ad6b4475a31ba1f49c8a
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 15c30be..e4cf582 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -361,7 +361,7 @@
void BatteryMonitor::updateValues(void) {
initHealthInfo(mHealthInfo.get());
- if (!mHealthdConfig->batteryPresentPath.isEmpty())
+ if (!mHealthdConfig->batteryPresentPath.empty())
mHealthInfo->batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath);
else
mHealthInfo->batteryPresent = mBatteryDevicePresent;
@@ -371,43 +371,43 @@
: getIntField(mHealthdConfig->batteryCapacityPath);
mHealthInfo->batteryVoltageMillivolts = getIntField(mHealthdConfig->batteryVoltagePath) / 1000;
- if (!mHealthdConfig->batteryCurrentNowPath.isEmpty())
+ if (!mHealthdConfig->batteryCurrentNowPath.empty())
mHealthInfo->batteryCurrentMicroamps = getIntField(mHealthdConfig->batteryCurrentNowPath);
- if (!mHealthdConfig->batteryFullChargePath.isEmpty())
+ if (!mHealthdConfig->batteryFullChargePath.empty())
mHealthInfo->batteryFullChargeUah = getIntField(mHealthdConfig->batteryFullChargePath);
- if (!mHealthdConfig->batteryCycleCountPath.isEmpty())
+ if (!mHealthdConfig->batteryCycleCountPath.empty())
mHealthInfo->batteryCycleCount = getIntField(mHealthdConfig->batteryCycleCountPath);
- if (!mHealthdConfig->batteryChargeCounterPath.isEmpty())
+ if (!mHealthdConfig->batteryChargeCounterPath.empty())
mHealthInfo->batteryChargeCounterUah =
getIntField(mHealthdConfig->batteryChargeCounterPath);
- if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty())
+ if (!mHealthdConfig->batteryCurrentAvgPath.empty())
mHealthInfo->batteryCurrentAverageMicroamps =
getIntField(mHealthdConfig->batteryCurrentAvgPath);
- if (!mHealthdConfig->batteryChargeTimeToFullNowPath.isEmpty())
+ if (!mHealthdConfig->batteryChargeTimeToFullNowPath.empty())
mHealthInfo->batteryChargeTimeToFullNowSeconds =
getIntField(mHealthdConfig->batteryChargeTimeToFullNowPath);
- if (!mHealthdConfig->batteryFullChargeDesignCapacityUahPath.isEmpty())
+ if (!mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty())
mHealthInfo->batteryFullChargeDesignCapacityUah =
getIntField(mHealthdConfig->batteryFullChargeDesignCapacityUahPath);
- if (!mHealthdConfig->batteryHealthStatusPath.isEmpty())
+ if (!mHealthdConfig->batteryHealthStatusPath.empty())
mBatteryHealthStatus = getIntField(mHealthdConfig->batteryHealthStatusPath);
- if (!mHealthdConfig->batteryStateOfHealthPath.isEmpty())
+ if (!mHealthdConfig->batteryStateOfHealthPath.empty())
mHealthInfo->batteryHealthData->batteryStateOfHealth =
getIntField(mHealthdConfig->batteryStateOfHealthPath);
- if (!mHealthdConfig->batteryManufacturingDatePath.isEmpty())
+ if (!mHealthdConfig->batteryManufacturingDatePath.empty())
mHealthInfo->batteryHealthData->batteryManufacturingDateSeconds =
getIntField(mHealthdConfig->batteryManufacturingDatePath);
- if (!mHealthdConfig->batteryFirstUsageDatePath.isEmpty())
+ if (!mHealthdConfig->batteryFirstUsageDatePath.empty())
mHealthInfo->batteryHealthData->batteryFirstUsageSeconds =
getIntField(mHealthdConfig->batteryFirstUsageDatePath);
@@ -506,17 +506,17 @@
props.batteryStatus);
len = strlen(dmesgline);
- if (!healthd_config.batteryCurrentNowPath.isEmpty()) {
+ if (!healthd_config.batteryCurrentNowPath.empty()) {
len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d",
props.batteryCurrentMicroamps);
}
- if (!healthd_config.batteryFullChargePath.isEmpty()) {
+ if (!healthd_config.batteryFullChargePath.empty()) {
len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d",
props.batteryFullChargeUah);
}
- if (!healthd_config.batteryCycleCountPath.isEmpty()) {
+ if (!healthd_config.batteryCycleCountPath.empty()) {
len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d",
props.batteryCycleCount);
}
@@ -550,7 +550,7 @@
int BatteryMonitor::getChargeStatus() {
BatteryStatus result = BatteryStatus::UNKNOWN;
- if (!mHealthdConfig->batteryStatusPath.isEmpty()) {
+ if (!mHealthdConfig->batteryStatusPath.empty()) {
std::string buf;
if (readFromFile(mHealthdConfig->batteryStatusPath, &buf) > 0)
result = getBatteryStatus(buf.c_str());
@@ -561,7 +561,7 @@
status_t BatteryMonitor::setChargingPolicy(int value) {
status_t ret = NAME_NOT_FOUND;
bool result;
- if (!mHealthdConfig->chargingPolicyPath.isEmpty()) {
+ if (!mHealthdConfig->chargingPolicyPath.empty()) {
result = writeToFile(mHealthdConfig->chargingPolicyPath, value);
if (!result) {
KLOG_WARNING(LOG_TAG, "setChargingPolicy fail\n");
@@ -575,7 +575,7 @@
int BatteryMonitor::getChargingPolicy() {
BatteryChargingPolicy result = BatteryChargingPolicy::DEFAULT;
- if (!mHealthdConfig->chargingPolicyPath.isEmpty()) {
+ if (!mHealthdConfig->chargingPolicyPath.empty()) {
std::string buf;
if (readFromFile(mHealthdConfig->chargingPolicyPath, &buf) > 0)
result = getBatteryChargingPolicy(buf.c_str());
@@ -585,15 +585,15 @@
int BatteryMonitor::getBatteryHealthData(int id) {
if (id == BATTERY_PROP_MANUFACTURING_DATE) {
- if (!mHealthdConfig->batteryManufacturingDatePath.isEmpty())
+ if (!mHealthdConfig->batteryManufacturingDatePath.empty())
return getIntField(mHealthdConfig->batteryManufacturingDatePath);
}
if (id == BATTERY_PROP_FIRST_USAGE_DATE) {
- if (!mHealthdConfig->batteryFirstUsageDatePath.isEmpty())
+ if (!mHealthdConfig->batteryFirstUsageDatePath.empty())
return getIntField(mHealthdConfig->batteryFirstUsageDatePath);
}
if (id == BATTERY_PROP_STATE_OF_HEALTH) {
- if (!mHealthdConfig->batteryStateOfHealthPath.isEmpty())
+ if (!mHealthdConfig->batteryStateOfHealthPath.empty())
return getIntField(mHealthdConfig->batteryStateOfHealthPath);
}
return 0;
@@ -607,7 +607,7 @@
switch(id) {
case BATTERY_PROP_CHARGE_COUNTER:
- if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
+ if (!mHealthdConfig->batteryChargeCounterPath.empty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryChargeCounterPath);
ret = OK;
@@ -617,7 +617,7 @@
break;
case BATTERY_PROP_CURRENT_NOW:
- if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
+ if (!mHealthdConfig->batteryCurrentNowPath.empty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryCurrentNowPath);
ret = OK;
@@ -627,7 +627,7 @@
break;
case BATTERY_PROP_CURRENT_AVG:
- if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) {
+ if (!mHealthdConfig->batteryCurrentAvgPath.empty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryCurrentAvgPath);
ret = OK;
@@ -637,7 +637,7 @@
break;
case BATTERY_PROP_CAPACITY:
- if (!mHealthdConfig->batteryCapacityPath.isEmpty()) {
+ if (!mHealthdConfig->batteryCapacityPath.empty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryCapacityPath);
ret = OK;
@@ -704,35 +704,35 @@
props.batteryVoltageMillivolts, props.batteryTemperatureTenthsCelsius);
write(fd, vs, strlen(vs));
- if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
+ if (!mHealthdConfig->batteryCurrentNowPath.empty()) {
v = getIntField(mHealthdConfig->batteryCurrentNowPath);
snprintf(vs, sizeof(vs), "current now: %d\n", v);
write(fd, vs, strlen(vs));
}
- if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) {
+ if (!mHealthdConfig->batteryCurrentAvgPath.empty()) {
v = getIntField(mHealthdConfig->batteryCurrentAvgPath);
snprintf(vs, sizeof(vs), "current avg: %d\n", v);
write(fd, vs, strlen(vs));
}
- if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
+ if (!mHealthdConfig->batteryChargeCounterPath.empty()) {
v = getIntField(mHealthdConfig->batteryChargeCounterPath);
snprintf(vs, sizeof(vs), "charge counter: %d\n", v);
write(fd, vs, strlen(vs));
}
- if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
+ if (!mHealthdConfig->batteryCurrentNowPath.empty()) {
snprintf(vs, sizeof(vs), "current now: %d\n", props.batteryCurrentMicroamps);
write(fd, vs, strlen(vs));
}
- if (!mHealthdConfig->batteryCycleCountPath.isEmpty()) {
+ if (!mHealthdConfig->batteryCycleCountPath.empty()) {
snprintf(vs, sizeof(vs), "cycle count: %d\n", props.batteryCycleCount);
write(fd, vs, strlen(vs));
}
- if (!mHealthdConfig->batteryFullChargePath.isEmpty()) {
+ if (!mHealthdConfig->batteryFullChargePath.empty()) {
snprintf(vs, sizeof(vs), "Full charge: %d\n", props.batteryFullChargeUah);
write(fd, vs, strlen(vs));
}
@@ -782,7 +782,7 @@
if (isScopedPowerSupply(name)) continue;
mBatteryDevicePresent = true;
- if (mHealthdConfig->batteryStatusPath.isEmpty()) {
+ if (mHealthdConfig->batteryStatusPath.empty()) {
path.clear();
path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
name);
@@ -790,7 +790,7 @@
mHealthdConfig->batteryStatusPath = path;
}
- if (mHealthdConfig->batteryHealthPath.isEmpty()) {
+ if (mHealthdConfig->batteryHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
name);
@@ -798,7 +798,7 @@
mHealthdConfig->batteryHealthPath = path;
}
- if (mHealthdConfig->batteryPresentPath.isEmpty()) {
+ if (mHealthdConfig->batteryPresentPath.empty()) {
path.clear();
path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
name);
@@ -806,7 +806,7 @@
mHealthdConfig->batteryPresentPath = path;
}
- if (mHealthdConfig->batteryCapacityPath.isEmpty()) {
+ if (mHealthdConfig->batteryCapacityPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
@@ -814,7 +814,7 @@
mHealthdConfig->batteryCapacityPath = path;
}
- if (mHealthdConfig->batteryVoltagePath.isEmpty()) {
+ if (mHealthdConfig->batteryVoltagePath.empty()) {
path.clear();
path.appendFormat("%s/%s/voltage_now",
POWER_SUPPLY_SYSFS_PATH, name);
@@ -823,7 +823,7 @@
}
}
- if (mHealthdConfig->batteryFullChargePath.isEmpty()) {
+ if (mHealthdConfig->batteryFullChargePath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full",
POWER_SUPPLY_SYSFS_PATH, name);
@@ -831,7 +831,7 @@
mHealthdConfig->batteryFullChargePath = path;
}
- if (mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
+ if (mHealthdConfig->batteryCurrentNowPath.empty()) {
path.clear();
path.appendFormat("%s/%s/current_now",
POWER_SUPPLY_SYSFS_PATH, name);
@@ -839,7 +839,7 @@
mHealthdConfig->batteryCurrentNowPath = path;
}
- if (mHealthdConfig->batteryCycleCountPath.isEmpty()) {
+ if (mHealthdConfig->batteryCycleCountPath.empty()) {
path.clear();
path.appendFormat("%s/%s/cycle_count",
POWER_SUPPLY_SYSFS_PATH, name);
@@ -847,27 +847,27 @@
mHealthdConfig->batteryCycleCountPath = path;
}
- if (mHealthdConfig->batteryCapacityLevelPath.isEmpty()) {
+ 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 (mHealthdConfig->batteryChargeTimeToFullNowPath.isEmpty()) {
+ 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)
mHealthdConfig->batteryChargeTimeToFullNowPath = path;
}
- if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.isEmpty()) {
+ if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
if (access(path, R_OK) == 0)
mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
}
- if (mHealthdConfig->batteryCurrentAvgPath.isEmpty()) {
+ if (mHealthdConfig->batteryCurrentAvgPath.empty()) {
path.clear();
path.appendFormat("%s/%s/current_avg",
POWER_SUPPLY_SYSFS_PATH, name);
@@ -875,7 +875,7 @@
mHealthdConfig->batteryCurrentAvgPath = path;
}
- if (mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
+ if (mHealthdConfig->batteryChargeCounterPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_counter",
POWER_SUPPLY_SYSFS_PATH, name);
@@ -883,7 +883,7 @@
mHealthdConfig->batteryChargeCounterPath = path;
}
- if (mHealthdConfig->batteryTemperaturePath.isEmpty()) {
+ if (mHealthdConfig->batteryTemperaturePath.empty()) {
path.clear();
path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
name);
@@ -892,7 +892,7 @@
}
}
- if (mHealthdConfig->batteryTechnologyPath.isEmpty()) {
+ if (mHealthdConfig->batteryTechnologyPath.empty()) {
path.clear();
path.appendFormat("%s/%s/technology",
POWER_SUPPLY_SYSFS_PATH, name);
@@ -900,7 +900,7 @@
mHealthdConfig->batteryTechnologyPath = path;
}
- if (mHealthdConfig->batteryStateOfHealthPath.isEmpty()) {
+ if (mHealthdConfig->batteryStateOfHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/state_of_health", POWER_SUPPLY_SYSFS_PATH, name);
if (access(path, R_OK) == 0) {
@@ -913,32 +913,32 @@
}
}
- if (mHealthdConfig->batteryHealthStatusPath.isEmpty()) {
+ 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 (mHealthdConfig->batteryManufacturingDatePath.isEmpty()) {
+ if (mHealthdConfig->batteryManufacturingDatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/manufacturing_date", POWER_SUPPLY_SYSFS_PATH, name);
if (access(path, R_OK) == 0)
mHealthdConfig->batteryManufacturingDatePath = path;
}
- if (mHealthdConfig->batteryFirstUsageDatePath.isEmpty()) {
+ 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 (mHealthdConfig->chargingStatePath.isEmpty()) {
+ 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 (mHealthdConfig->chargingPolicyPath.isEmpty()) {
+ 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;
@@ -968,43 +968,43 @@
hc->periodic_chores_interval_fast = -1;
hc->periodic_chores_interval_slow = -1;
} else {
- if (mHealthdConfig->batteryStatusPath.isEmpty())
+ if (mHealthdConfig->batteryStatusPath.empty())
KLOG_WARNING(LOG_TAG, "BatteryStatusPath not found\n");
- if (mHealthdConfig->batteryHealthPath.isEmpty())
+ if (mHealthdConfig->batteryHealthPath.empty())
KLOG_WARNING(LOG_TAG, "BatteryHealthPath not found\n");
- if (mHealthdConfig->batteryPresentPath.isEmpty())
+ if (mHealthdConfig->batteryPresentPath.empty())
KLOG_WARNING(LOG_TAG, "BatteryPresentPath not found\n");
- if (mHealthdConfig->batteryCapacityPath.isEmpty())
+ if (mHealthdConfig->batteryCapacityPath.empty())
KLOG_WARNING(LOG_TAG, "BatteryCapacityPath not found\n");
- if (mHealthdConfig->batteryVoltagePath.isEmpty())
+ if (mHealthdConfig->batteryVoltagePath.empty())
KLOG_WARNING(LOG_TAG, "BatteryVoltagePath not found\n");
- if (mHealthdConfig->batteryTemperaturePath.isEmpty())
+ if (mHealthdConfig->batteryTemperaturePath.empty())
KLOG_WARNING(LOG_TAG, "BatteryTemperaturePath not found\n");
- if (mHealthdConfig->batteryTechnologyPath.isEmpty())
+ if (mHealthdConfig->batteryTechnologyPath.empty())
KLOG_WARNING(LOG_TAG, "BatteryTechnologyPath not found\n");
- if (mHealthdConfig->batteryCurrentNowPath.isEmpty())
+ if (mHealthdConfig->batteryCurrentNowPath.empty())
KLOG_WARNING(LOG_TAG, "BatteryCurrentNowPath not found\n");
- if (mHealthdConfig->batteryFullChargePath.isEmpty())
+ if (mHealthdConfig->batteryFullChargePath.empty())
KLOG_WARNING(LOG_TAG, "BatteryFullChargePath not found\n");
- if (mHealthdConfig->batteryCycleCountPath.isEmpty())
+ if (mHealthdConfig->batteryCycleCountPath.empty())
KLOG_WARNING(LOG_TAG, "BatteryCycleCountPath not found\n");
- if (mHealthdConfig->batteryCapacityLevelPath.isEmpty())
+ if (mHealthdConfig->batteryCapacityLevelPath.empty())
KLOG_WARNING(LOG_TAG, "batteryCapacityLevelPath not found\n");
- if (mHealthdConfig->batteryChargeTimeToFullNowPath.isEmpty())
+ if (mHealthdConfig->batteryChargeTimeToFullNowPath.empty())
KLOG_WARNING(LOG_TAG, "batteryChargeTimeToFullNowPath. not found\n");
- if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.isEmpty())
+ if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty())
KLOG_WARNING(LOG_TAG, "batteryFullChargeDesignCapacityUahPath. not found\n");
- if (mHealthdConfig->batteryStateOfHealthPath.isEmpty())
+ if (mHealthdConfig->batteryStateOfHealthPath.empty())
KLOG_WARNING(LOG_TAG, "batteryStateOfHealthPath not found\n");
- if (mHealthdConfig->batteryHealthStatusPath.isEmpty())
+ if (mHealthdConfig->batteryHealthStatusPath.empty())
KLOG_WARNING(LOG_TAG, "batteryHealthStatusPath not found\n");
- if (mHealthdConfig->batteryManufacturingDatePath.isEmpty())
+ if (mHealthdConfig->batteryManufacturingDatePath.empty())
KLOG_WARNING(LOG_TAG, "batteryManufacturingDatePath not found\n");
- if (mHealthdConfig->batteryFirstUsageDatePath.isEmpty())
+ if (mHealthdConfig->batteryFirstUsageDatePath.empty())
KLOG_WARNING(LOG_TAG, "batteryFirstUsageDatePath not found\n");
- if (mHealthdConfig->chargingStatePath.isEmpty())
+ if (mHealthdConfig->chargingStatePath.empty())
KLOG_WARNING(LOG_TAG, "chargingStatePath not found\n");
- if (mHealthdConfig->chargingPolicyPath.isEmpty())
+ if (mHealthdConfig->chargingPolicyPath.empty())
KLOG_WARNING(LOG_TAG, "chargingPolicyPath not found\n");
}