I found the file sys/devices/platform/battery/LGBM_AtCmdChargingModeOff which has the value of "0". When I set it to 1, the phone stop charging.
String command1 = "chmod 777 /sys/devices/platform/battery/LGBM_AtCmdChargingModeOff;";
String command2 = "echo \"1\" > /sys/devices/platform/battery/LGBM_AtCmdChargingModeOff;";
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command1, command2}, null);
proc.waitFor();
When I try to set it back to 0, it keep staying at 1. I don't get any failure, so some other process must re-write the file (when /i try to do it manually, I get "error saving the file"). After restart of the phone, the file's value is back to "0". Any idea how to get the phone charging again, without restarting it?
I have the same issue and was looking for a solution for the past 3-4 years!
There is an app on the Google Play Store called Battery Charge Limit, however it is not maintained anymore and doesn't work with alot of (newer) phones.
Finally, I found this project! Advanced Charging Controller (ACC) (Magisk fork).
"ACC is primarily intended for extending battery service life".
It's a Magisk module, but you can make it work with any root solution.
I'm running it on 3 phones and it appears to work so far!
It comes with awesome features such as these:
acc -d 70% (do not recharge until capacity drops to 70%)
acc -d 1h (do not recharge until 1 hour has passed)
acc -e 30m (recharge for 30 minutes)
acc -s endurance+ (a.k.a, "the li-ion sweet spot"; best for GPS navigation and other long operations)
acc -s travel (for when you need extra juice)
Background why I need this feature:
I develop a Raspberry Pi + Android phone solution, where the phone is plugged-in and charging 24/7, such that the battery remains at 100% charge all the time. Li-Ion batteries don't like it and will start to expand inside the phone and damage the device, sometimes to a point where they break. I have to replace batteries every 1-3 years, and in some cases even randomly after approx. 6 months (the price range for the used android phones is around $100-200, usually LG K4 and Moto G/E phones). Now my goal is to keep the battery at a comfortable charge level (around 40-60%) and hopefuly make it last longer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With