The idea here is to replicate what all laptops do to preserve battery life. Here are my notes, as I dug through several mountains of uninformed drivel and useless/malware apps to find these valid options.
The "Chargie" app is the an expensive, but "no fuss" way to go.
If you have a bootloader-unlocked device, you can run ACC (Releases · VR-25/acc · GitHub) and AccA (Releases · MatteCarra/AccA · GitHub). These allow directly powering the device and bypassing the battery entirely. If the device loses power, it will then
revert to battery.
If you have not unlocked the device then you can use Tasker and AutoInput.
Install Tasker/AutoInput, then slog through "setup", "accessibility", and "write secure adb" configurations. Both apps do a decent job of leading you by the nose on this.
Create two Tasker profiles with state = power
and source = AC
.
Toggle Invert
for one of the profiles.
The Invert
profile turns on the plug when your battery drops too low.
The 2nd profile turns off the plug when the battery is charged to a specified charge level.
Link your profile active when power is on (AC not Inverted) to the task that turns off when the battery hits 70%.
Link the Invert profile to the one that turns on when the battery hits 30%.
There ya go. Here is a link to tasker tasks that do as stated above, and can be a starting point for your own config. Download with any android device.
Easier to type link - https://tinyurl.com/4r7f238s