Enable the battery defender
Battery defender aims to extend the life of the battery when a device
is plugged in for too long (2 weeks).
Test: Set BatteryDefender.h constructor thresholds to 1 minute.
Ensure that the SOC charge thresholds change to 60/70
when connected to power for 1 minute.
Bug: 146318912
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: I47d21c5c557a1f478b6d5fa26c02b81f32432d3b
diff --git a/health/HealthService.cpp b/health/HealthService.cpp
index cfbe339..ffe96bb 100644
--- a/health/HealthService.cpp
+++ b/health/HealthService.cpp
@@ -22,6 +22,7 @@
#include <health2/service.h>
#include <healthd/healthd.h>
#include <hidl/HidlTransportSupport.h>
+#include <pixelhealth/BatteryDefender.h>
#include <pixelhealth/BatteryMetricsLogger.h>
#include <pixelhealth/BatteryThermalControl.h>
#include <pixelhealth/CycleCountBackupRestore.h>
@@ -45,6 +46,7 @@
using ::device::google::bonito::health::BatteryRechargingControl;
using ::device::google::bonito::health::BatteryInfoUpdate;
using ::device::google::bonito::health::LearnedCapacityBackupRestore;
+using hardware::google::pixel::health::BatteryDefender;
using hardware::google::pixel::health::BatteryMetricsLogger;
using hardware::google::pixel::health::BatteryThermalControl;
using hardware::google::pixel::health::CycleCountBackupRestore;
@@ -57,6 +59,7 @@
constexpr char kVoltageAvg[] {FG_DIR "/battery/voltage_now"};
constexpr char kCycleCountsBins[] {FG_DIR "/bms/device/cycle_counts_bins"};
+static BatteryDefender battDefender;
static BatteryRechargingControl battRechargingControl;
static BatteryInfoUpdate battInfoUpdate;
static BatteryThermalControl battThermalControl("sys/devices/virtual/thermal/tz-by-name/soc/mode");
@@ -109,6 +112,7 @@
void healthd_board_init(struct healthd_config*) {
ccBackupRestoreBMS.Restore();
lcBackupRestore.Restore();
+ battDefender.update();
}
int healthd_board_battery_update(struct android::BatteryProperties *props) {
@@ -120,6 +124,7 @@
shutdownMetrics.logShutdownVoltage(props);
ccBackupRestoreBMS.Backup(props->batteryLevel);
lcBackupRestore.Backup();
+ battDefender.update();
return 0;
}
diff --git a/init.hardware.rc b/init.hardware.rc
index 051dea1..7313f38 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -142,6 +142,10 @@
# Property used by vintf for sku specific manifests
setprop ro.boot.product.hardware.sku ${ro.boot.hardware.sku}
+ # Battery Defender
+ chown system system /sys/devices/platform/soc/soc:google,charger/charge_stop_level
+ chown system system /sys/devices/platform/soc/soc:google,charger/charge_start_level
+
on late-init
setprop vendor.thermal.config thermal_info_config.json
chown system system /sys/devices/virtual/thermal/tz-by-name/mb-therm-monitor/trip_point_0_temp
@@ -804,12 +808,6 @@
setprop persist.vendor.charge.stop.level 35
setprop persist.vendor.charge.start.level 30
-on property:persist.vendor.charge.stop.level=*
- write /sys/devices/platform/soc/soc:google,charger/charge_stop_level ${persist.vendor.charge.stop.level}
-
-on property:persist.vendor.charge.start.level=*
- write /sys/devices/platform/soc/soc:google,charger/charge_start_level ${persist.vendor.charge.start.level}
-
# For Japan radio builds, always enforce camera shutter sound
# Since this property is read by the audio server in system service,
# it should be written by the system init.