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?