init: support boot.charger_mode feature
1. If the device is powered off by users, boot to charger mode
after plugging in the charger. Otherwise, boot to OS.
2. Disable this feature by default
3. Enable this feature by persist.sys.boot.charger_mode.enable=1
Bug: 251680171
Test: can enter charger mode from power off
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: Ibd1f88c961d884d8e6f9d0019cf550fd0de1192d
diff --git a/conf/init.gs101.rc b/conf/init.gs101.rc
index 3a62a0c..d156905 100644
--- a/conf/init.gs101.rc
+++ b/conf/init.gs101.rc
@@ -309,6 +309,9 @@
# Disable dock-defend by default
chown system system /sys/devices/platform/google,charger/dd_settings
write /sys/devices/platform/google,charger/dd_settings -1
+ # Enable charger mode (aka off-mode charging) by default
+ chown system system /sys/class/power_supply/battery/charger_mode
+ write /sys/class/power_supply/battery/charger_mode 1
# Power Stats HAL
chown system system /dev/bbd_pwrstat
@@ -828,6 +831,14 @@
setprop persist.vendor.charge.start.level 0
setprop vendor.battery.defender.disable 1
+# Clear the state of charger_mode
+on property:persist.vendor.charger_mode.enable=1
+ write /sys/class/power_supply/battery/charger_mode 0
+
+# Enable charger_mode when user triggers shutdown from menu
+on property:sys.shutdown.requested=0userrequested
+ write /sys/class/power_supply/battery/charger_mode 1
+
# ACA (Adaptice Charge Always On) persist properties
on property:persist.vendor.adaptive.charge.soc=*
write /sys/class/power_supply/battery/charge_limit ${persist.vendor.adaptive.charge.soc}