I've installed Lineage on a Samsung tab s2 which I use in the car. I've added the following to get it to auto start when it goes on charge
# /system/etc/init/off_mode_charge.rc
on charger
setprop sys.powerctl reboot,leaving-off-mode-charging
But does anyone know a way to add a script to the startup routine so if the battery is below say 10% it won't continue starting? I use tasker to power off the tablet when the usb power drops but there have been a couple of times for some reason it doesn't, meaning the battery can drop to 0% and then it goes into a restart loop as the low power supply in the car isn't enough during startup. I can read the power using the capacity file in /sys/class/power_supply/battery/ just not sure how, or if, I can add a script to the startup sequence to use this.
Thanks
setprop sys.powerctl ...
directly from.rc
file. Instead useexec
orexec_background
to run a shell script which first checks battery level or any other conditions. Already mentioned in the last point of my answer from where you copied theoff_mode_charge.rc
file: android.stackexchange.com/a/221384/218526