Health: Add Battery Thermal control for SOC
This is to enable to disabling of SOC based throttling
when charging is enabled. Throttling is re-enabled once
device is no longer charging.
Bug: 131314951
Test: Use emul_temp and battery/capacity to emulate
condition for checking if SOC thermal zone is
disabled/enabled.
Signed-off-by: George Lee <geolee@google.com>
Change-Id: I7a4286bf2e55afb37937bb7bdc43cd21f1d1feaf
diff --git a/health/HealthService.cpp b/health/HealthService.cpp
index fec8692..70416b0 100644
--- a/health/HealthService.cpp
+++ b/health/HealthService.cpp
@@ -14,9 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "android.hardware.health@2.0-service.crosshatch"
-#include <android-base/logging.h>
-
#include <android-base/file.h>
+#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
#include <health2/Health.h>
@@ -24,6 +23,7 @@
#include <healthd/healthd.h>
#include <hidl/HidlTransportSupport.h>
#include <pixelhealth/BatteryMetricsLogger.h>
+#include <pixelhealth/BatteryThermalControl.h>
#include <pixelhealth/CycleCountBackupRestore.h>
#include <pixelhealth/DeviceHealth.h>
#include <pixelhealth/LowBatteryShutdownMetrics.h>
@@ -40,17 +40,19 @@
using android::hardware::health::V2_0::DiskStats;
using android::hardware::health::V2_0::StorageAttribute;
using android::hardware::health::V2_0::StorageInfo;
+using ::device::google::crosshatch::health::BatteryRechargingControl;
using hardware::google::pixel::health::BatteryMetricsLogger;
+using hardware::google::pixel::health::BatteryThermalControl;
using hardware::google::pixel::health::CycleCountBackupRestore;
using hardware::google::pixel::health::DeviceHealth;
using hardware::google::pixel::health::LowBatteryShutdownMetrics;
-using ::device::google::crosshatch::health::BatteryRechargingControl;
constexpr char kBatteryResistance[] = "/sys/class/power_supply/maxfg/resistance";
constexpr char kBatteryOCV[] = "/sys/class/power_supply/maxfg/voltage_ocv";
constexpr char kVoltageAvg[] = "/sys/class/power_supply/maxfg/voltage_avg";
static BatteryRechargingControl battRechargingControl;
+static BatteryThermalControl battThermalControl("sys/devices/virtual/thermal/tz-by-name/soc/mode");
static BatteryMetricsLogger battMetricsLogger(kBatteryResistance, kBatteryOCV);
static LowBatteryShutdownMetrics shutdownMetrics(kVoltageAvg);
static CycleCountBackupRestore ccBackupRestoreBMS(
@@ -112,6 +114,7 @@
int healthd_board_battery_update(struct android::BatteryProperties *props) {
battRechargingControl.updateBatteryProperties(props);
deviceHealth.update(props);
+ battThermalControl.updateThermalState(props);
battMetricsLogger.logBatteryProperties(props);
shutdownMetrics.logShutdownVoltage(props);
ccBackupRestoreBMS.Backup(props->batteryLevel);
diff --git a/init.hardware.rc b/init.hardware.rc
index 0d9d1ef..70c5b59 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -174,6 +174,7 @@
chown system system /sys/devices/virtual/thermal/tz-by-name/fps-therm-monitor/trip_point_0_hyst
chown system system /sys/devices/virtual/thermal/tz-by-name/usbc-therm-monitor/trip_point_0_temp
chown system system /sys/devices/virtual/thermal/tz-by-name/usbc-therm-monitor/trip_point_0_hyst
+ chown system system /sys/devices/virtual/thermal/tz-by-name/soc/mode
on fs
mount_all /vendor/etc/fstab.${ro.boot.hardware.platform} --early