by Carlchristian Eckert
The aim of this flow is to avoid charging the battery above a certain threshold (preset is 80%) in order to mitigate performance drops of the battery over the lifetime of your phone. While it is not possible to automatically stop the charging process without root access, this flow can notify the user to unplug the charger.
What the algorithm does:
When the battery reaches 80% charge (during charging), warn the user with a notification, sound and vibration. The acoustic warning is repeated every 30s until the charger is removed.
The fiber can keep running in the background indefinitely an will handle plugging/unplugging of the charger correctly. Battery impact while not charging is minimal, as the flow will keep waiting for the charger to be plugged in.
What this algorithm does NOT: stop the charging process. (If you have root access, it might be easy to adapt the flow)