From f59712928233f6abadd888e7d014b6fa4a20e932 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 14 Aug 2023 18:18:26 +0000 Subject: [PATCH] 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 --- healthd/BatteryMonitor.cpp | 142 +++++++++++++++++----------------- healthd/BatteryMonitor_v1.cpp | 100 ++++++++++++------------ libutils/String8_fuzz.cpp | 2 +- 3 files changed, 122 insertions(+), 122 deletions(-) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 15c30be41..e4cf582fb 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -361,7 +361,7 @@ static bool isScopedPowerSupply(const char* name) { 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 @@ void BatteryMonitor::updateValues(void) { : 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 @@ static void doLogValues(const HealthInfo& props, const struct healthd_config& he 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 @@ bool BatteryMonitor::isChargerOnline() { 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 @@ int BatteryMonitor::getChargeStatus() { 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 @@ status_t BatteryMonitor::setChargingPolicy(int value) { 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::getChargingPolicy() { 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 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { 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 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { 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 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { 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 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { break; case BATTERY_PROP_CAPACITY: - if (!mHealthdConfig->batteryCapacityPath.isEmpty()) { + if (!mHealthdConfig->batteryCapacityPath.empty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryCapacityPath); ret = OK; @@ -704,35 +704,35 @@ void BatteryMonitor::dumpState(int fd) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { } } - 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { } } - if (mHealthdConfig->batteryTechnologyPath.isEmpty()) { + if (mHealthdConfig->batteryTechnologyPath.empty()) { path.clear(); path.appendFormat("%s/%s/technology", POWER_SUPPLY_SYSFS_PATH, name); @@ -900,7 +900,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { } } - 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 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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"); } diff --git a/healthd/BatteryMonitor_v1.cpp b/healthd/BatteryMonitor_v1.cpp index b2d6518f7..686c338cc 100644 --- a/healthd/BatteryMonitor_v1.cpp +++ b/healthd/BatteryMonitor_v1.cpp @@ -301,7 +301,7 @@ static bool isScopedPowerSupply(const char* name) { void BatteryMonitor::updateValues(void) { initHealthInfo(mHealthInfo.get()); - if (!mHealthdConfig->batteryPresentPath.isEmpty()) + if (!mHealthdConfig->batteryPresentPath.empty()) mHealthInfo->batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath); else mHealthInfo->batteryPresent = mBatteryDevicePresent; @@ -311,28 +311,28 @@ void BatteryMonitor::updateValues(void) { : 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); @@ -420,17 +420,17 @@ static void doLogValues(const HealthInfo& props, const struct healthd_config& he 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); } @@ -464,7 +464,7 @@ bool BatteryMonitor::isChargerOnline() { 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()); @@ -480,7 +480,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { switch(id) { case BATTERY_PROP_CHARGE_COUNTER: - if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) { + if (!mHealthdConfig->batteryChargeCounterPath.empty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryChargeCounterPath); ret = OK; @@ -490,7 +490,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { break; case BATTERY_PROP_CURRENT_NOW: - if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) { + if (!mHealthdConfig->batteryCurrentNowPath.empty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryCurrentNowPath); ret = OK; @@ -500,7 +500,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { break; case BATTERY_PROP_CURRENT_AVG: - if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) { + if (!mHealthdConfig->batteryCurrentAvgPath.empty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryCurrentAvgPath); ret = OK; @@ -510,7 +510,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { break; case BATTERY_PROP_CAPACITY: - if (!mHealthdConfig->batteryCapacityPath.isEmpty()) { + if (!mHealthdConfig->batteryCapacityPath.empty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryCapacityPath); ret = OK; @@ -557,35 +557,35 @@ void BatteryMonitor::dumpState(int fd) { 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)); } @@ -635,7 +635,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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); @@ -643,7 +643,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryStatusPath = path; } - if (mHealthdConfig->batteryHealthPath.isEmpty()) { + if (mHealthdConfig->batteryHealthPath.empty()) { path.clear(); path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH, name); @@ -651,7 +651,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryHealthPath = path; } - if (mHealthdConfig->batteryPresentPath.isEmpty()) { + if (mHealthdConfig->batteryPresentPath.empty()) { path.clear(); path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH, name); @@ -659,7 +659,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryPresentPath = path; } - if (mHealthdConfig->batteryCapacityPath.isEmpty()) { + if (mHealthdConfig->batteryCapacityPath.empty()) { path.clear(); path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH, name); @@ -667,7 +667,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryCapacityPath = path; } - if (mHealthdConfig->batteryVoltagePath.isEmpty()) { + if (mHealthdConfig->batteryVoltagePath.empty()) { path.clear(); path.appendFormat("%s/%s/voltage_now", POWER_SUPPLY_SYSFS_PATH, name); @@ -676,7 +676,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { } } - if (mHealthdConfig->batteryFullChargePath.isEmpty()) { + if (mHealthdConfig->batteryFullChargePath.empty()) { path.clear(); path.appendFormat("%s/%s/charge_full", POWER_SUPPLY_SYSFS_PATH, name); @@ -684,7 +684,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryFullChargePath = path; } - if (mHealthdConfig->batteryCurrentNowPath.isEmpty()) { + if (mHealthdConfig->batteryCurrentNowPath.empty()) { path.clear(); path.appendFormat("%s/%s/current_now", POWER_SUPPLY_SYSFS_PATH, name); @@ -692,7 +692,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryCurrentNowPath = path; } - if (mHealthdConfig->batteryCycleCountPath.isEmpty()) { + if (mHealthdConfig->batteryCycleCountPath.empty()) { path.clear(); path.appendFormat("%s/%s/cycle_count", POWER_SUPPLY_SYSFS_PATH, name); @@ -700,27 +700,27 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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); @@ -728,7 +728,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryCurrentAvgPath = path; } - if (mHealthdConfig->batteryChargeCounterPath.isEmpty()) { + if (mHealthdConfig->batteryChargeCounterPath.empty()) { path.clear(); path.appendFormat("%s/%s/charge_counter", POWER_SUPPLY_SYSFS_PATH, name); @@ -736,7 +736,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { mHealthdConfig->batteryChargeCounterPath = path; } - if (mHealthdConfig->batteryTemperaturePath.isEmpty()) { + if (mHealthdConfig->batteryTemperaturePath.empty()) { path.clear(); path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH, name); @@ -745,7 +745,7 @@ void BatteryMonitor::init(struct healthd_config *hc) { } } - if (mHealthdConfig->batteryTechnologyPath.isEmpty()) { + if (mHealthdConfig->batteryTechnologyPath.empty()) { path.clear(); path.appendFormat("%s/%s/technology", POWER_SUPPLY_SYSFS_PATH, name); @@ -777,31 +777,31 @@ void BatteryMonitor::init(struct healthd_config *hc) { 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"); } diff --git a/libutils/String8_fuzz.cpp b/libutils/String8_fuzz.cpp index e5dcd316e..09dcacd8a 100644 --- a/libutils/String8_fuzz.cpp +++ b/libutils/String8_fuzz.cpp @@ -34,7 +34,7 @@ std::vectorbytes(); }, [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void { - str1->isEmpty(); + str1->empty(); }, [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void { str1->length();