by Filipe Tavares
ROOT is required.
A small flow to limit charging the battery up to 80% and only return charging when under 70%. It checks if power supply plugged and disables enables/charge accordingly. While charging it checks battery % every 5 seconds.
Li-Ion and Li-Po life expectancy is increased if not charged over 80% and not discharged under 20%. Several studies prove it, google is your friend.
Tested on OnePlus 6 but should work if rooted and sys/class/power_supply/battery/charging_enabled is present. This variable can be modified manually to 1 or phone rebooted if not charging after use and under 70%.