From 331796ed8d7b880a7e52c7e7df4fc25e9b6c3699 Mon Sep 17 00:00:00 2001 From: Stephane Lee Date: Wed, 14 Apr 2021 17:09:25 -0700 Subject: [PATCH] BatteryDefender: Explicitly set wireless path to reduce errors logs For gs101 devices, we must detect whether a wireless charger exists at runtime, otherwise we'd need to create separate Health.cpp for each product in order to instantiate the wireless path correctly. Test: Ensure battery defender triggers via wireless connection. Ensure there are no warnings for devices that do not have a wireless charger Bug: 165954398 Change-Id: Ibba202293141c017d3048980b643a80b5fb57ca4 --- health/Health.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/health/Health.cpp b/health/Health.cpp index 9af0d342..f2b57be3 100644 --- a/health/Health.cpp +++ b/health/Health.cpp @@ -62,7 +62,9 @@ constexpr char kBatteryResistance[] {FG_DIR "/resistance"}; constexpr char kBatteryOCV[] {FG_DIR "/voltage_ocv"}; constexpr char kVoltageAvg[] {FG_DIR "/voltage_now"}; -static BatteryDefender battDefender; +#define WLC_DIR "/sys/class/power_supply/wireless" + +static BatteryDefender battDefender(WLC_DIR "/present"); static BatteryThermalControl battThermalControl( "dev/thermal/tz-by-name/soc/mode"); static BatteryMetricsLogger battMetricsLogger(kBatteryResistance, kBatteryOCV); @@ -84,7 +86,6 @@ static uint16_t lifetimeB; static std::chrono::system_clock::time_point ufs_last_query_time; constexpr auto kUfsQueryIntervalHours = std::chrono::hours{24}; -#define WLC_DIR "/sys/class/power_supply/wireless" static bool needs_wlc_updates = false; constexpr char kWlcCapacity[]{WLC_DIR "/capacity"}; @@ -132,6 +133,9 @@ void private_healthd_board_init(struct healthd_config *hc) { ChargerDetect::populateTcpmPsyName(&tcpmPsyName); hc->ignorePowerSupplyNames.push_back(android::String8(tcpmPsyName.c_str())); needs_wlc_updates = FileExists(kWlcCapacity); + if (needs_wlc_updates == false) { + battDefender.setWirelessNotSupported(); + } } int private_healthd_board_battery_update(struct android::BatteryProperties *props) {