dumpstate: Support dump TEMP-DEFEND/DWELL-DEFEND setting

Bug:175172404
Test: adb bugreport and check pass
Signed-off-by: Ted Lin <tedlin@google.com>
Change-Id: I73bf180dd81d8f826818dae2049ff6776e47ab4a
(cherry picked from commit d17cf6b06ec81c6c6b492d69ddf73beec2ab0bb5)
diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp
index 46e1bd6..fdcfb9a 100755
--- a/dumpstate/DumpstateDevice.cpp
+++ b/dumpstate/DumpstateDevice.cpp
@@ -483,6 +483,18 @@
     DumpFileToFd(fd, "Modem Stat", "/data/vendor/modem_stat/debug.txt");
     DumpFileToFd(fd, "Pixel trace", "/d/tracing/instances/pixel-trace/trace");
 
+    /* Battery Defend setting */
+    RunCommandToFd(
+        fd, "TEMP-DEFEND Config",
+        {"/vendor/bin/sh", "-c",
+         " cd /sys/devices/platform/soc/soc:google,charger; for f in `ls bd_*` ; do echo "
+         "\"$f: `cat $f`\" ; done"});
+    RunCommandToFd(
+        fd, "DWELL-DEFEND Config",
+        {"/vendor/bin/sh", "-c",
+         " cd /sys/devices/platform/soc/soc:google,charger; for f in `ls charge_s*` ; do echo "
+         "\"$f: `cat $f`\" ; done"});
+
     // Slower dump put later in case stuck the rest of dump
     // Timeout after 3s as TZ log missing EOF
     RunCommandToFd(fd, "QSEE logs", {"/vendor/bin/sh", "-c", "/vendor/bin/timeout 3 cat /d/tzdbg/qsee_log"});
diff --git a/init.hardware.rc b/init.hardware.rc
index 3965ded..480ccb2 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -164,6 +164,21 @@
     setprop vendor.thermal.vr_mode -novr
     setprop vendor.thermal.hw_mode -prod
 
+    # 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
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_drainto_soc
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_recharge_soc
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_recharge_voltage
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_resume_abs_temp
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_resume_soc
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_resume_temp
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_resume_time
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_trigger_temp
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_trigger_time
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_trigger_voltage
+    chown system system /sys/devices/platform/soc/soc:google,charger/bd_temp_enable
+
 on late-init
     write /sys/devices/virtual/thermal/tz-by-name/fps-therm-adc/mode enabled
     chown system system /sys/devices/virtual/thermal/tz-by-name/fps-therm-monitor/trip_point_0_temp