[Magisk] Fif_:
Great work.

Some compatibility/debug reports from the field...

Permissions and Values

This is the output of:

d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done

for a bunch of devices I own or have access to, all of them running Nougat with the ROM mentionned, Magisk 17.1 and the stock kernel for the ROM:

*** Nexus 4 running LOS 14.1 Nougat 7.1
-- No charger connected
-r--r--r-- 1 root root 4096 2018-10-01 18:02 usb/current_max = 100
-- AC Charger connected
-r--r--r-- 1 root root 4096 2018-10-01 18:02 usb/current_max = 1500
-- USB Charging connected
-r--r--r-- 1 root root 4096 2018-10-01 18:02 usb/current_max = 500
-- Wireless charging connected
-r--r--r-- 1 root root 4096 2018-10-01 18:02 usb/current_max = 1300

*** Nexus 5 running LOS 14.1 Nougat 7.1
-- No charger connected
-r--r--r-- 1 root root 4096 Jul 31 1970 ac/current_max = 1600000
-r--r--r-- 1 root root 4096 Oct 1 17:12 usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 17:12 wireless/current_max = 704000
-- AC Charger connected
-r--r--r-- 1 root root 4096 Jul 31 1970 ac/current_max = 1024000
-r--r--r-- 1 root root 4096 Oct 1 17:12 usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 17:12 wireless/current_max = 704000
-- USB Charging connected
-r--r--r-- 1 root root 4096 Jul 31 1970 ac/current_max = 1472000
-r--r--r-- 1 root root 4096 Oct 1 17:12 usb/current_max = 500000
-r--r--r-- 1 root root 4096 Oct 1 17:12 wireless/current_max = 704000
-- Wireless charging connected
-r--r--r-- 1 root root 4096 Jul 31 1970 ac/current_max = 704000
-r--r--r-- 1 root root 4096 Oct 1 17:12 usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 17:12 wireless/current_max = 704000

*** Nexus 5X running LOS 14.1 Nougat 7.1
-- No charger connected
-r--r--r-- 1 root root 4096 Oct 1 17:16 usb-parallel/current_max = 0
-r--r--r-- 1 root root 4096 Feb 10 1970 usb/current_max = 0
-- AC Charger connected
-r--r--r-- 1 root root 4096 Oct 1 17:16 usb-parallel/current_max = 2000
-r--r--r-- 1 root root 4096 Feb 10 1970 usb/current_max = 3000000
-- USB Charger connected
-r--r--r-- 1 root root 4096 Oct 1 17:16 usb-parallel/current_max = 2000
-r--r--r-- 1 root root 4096 Feb 10 1970 usb/current_max = 500000

*** OnePlus 5 running OOS 4.5 Nougat 7.1
-- No charger connected
-rw-r--r-- 1 root root 4096 Oct 1 17:10 dc/current_max = 500000
-rw-r--r-- 1 root root 4096 Oct 1 17:06 usb/current_max = -22
-- AC Charger connected (same as no charger)
-rw-r--r-- 1 root root 4096 Oct 1 17:10 dc/current_max = 500000
-rw-r--r-- 1 root root 4096 Oct 1 17:06 usb/current_max = -22
-- USB Charger connected
-rw-r--r-- 1 root root 4096 Oct 1 17:10 dc/current_max = 500000
-rw-r--r-- 1 root root 4096 Oct 1 17:06 usb/current_max = 500000

*** Samsung Galaxy Tab S2 (SM-T813 gts210vewifi) running LOS 14.1 Nougat 7.1
-- No charger connected
-rw-r--r-- 1 root root 4096 Oct 1 17:28 msm-usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 17:15 sm5703-charger/current_max = 450
-- AC Charger connected
-rw-r--r-- 1 root root 4096 Oct 1 17:28 msm-usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 17:28 sm5703-charger/current_max = 2100
-- USB Charger connected (same as no charger)
-rw-r--r-- 1 root root 4096 Oct 1 17:29 msm-usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 17:29 sm5703-charger/current_max = 450

Things I found

Nexus 4 (LOS 14.1 Nougat 7.1)

usb/current_max cannot be written to:

# echo 0 > /sys/class/power_supply/usb/current_max
bash: /sys/class/power_supply/usb/current_max: Permission denied

Changing the permissions of the file allows values to be written to but they are not remembered when either no power or USB power are connected:

# chmod 644 /sys/class/power_supply/usb/current_max
mako 0 # echo 0 > /sys/class/power_supply/usb/current_max
mako 0 # cat /sys/class/power_supply/usb/current_max
500

Changing current_max has no effect when USB power is connected.

However when AC power is connected, the current_max value can be lowered from 1500 to 500:

mako 0 # cat /sys/class/power_supply/usb/current_max
1500
mako 0 # echo 0 > /sys/class/power_supply/usb/current_max
mako 0 # cat /sys/class/power_supply/usb/current_max
500

It also seems to have an effect, when current_max is at 1500, AccuBattery report 800mA flowing in, while set to 0 (and limited to 500), the flow is only 200mA.

Nexus 5 (LOS 14.1 Nougat 7.1)

When plugged in an AC charger, echoing values into sysfs files doesn't work, the settings are not remembered or the write fails:

# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-r--r--r-- 1 root root 4096 Oct 1 21:16 ac/current_max = 1024000
-r--r--r-- 1 root root 4096 Oct 1 21:16 usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 21:16 wireless/current_max = 704000
# echo 0 > /sys/class/power_supply/ac/current_max
bash: /sys/class/power_supply/ac/current_max: Permission denied
# chmod +w /sys/class/power_supply/ac/current_max
# echo 0 > /sys/class/power_supply/ac/current_max
# cat /sys/class/power_supply/ac/current_max
1024000
# echo 1 > /sys/class/power_supply/ac/current_max
# cat /sys/class/power_supply/ac/current_max
1024000
# cat /sys/class/power_supply/wireless/current_max
704000
# echo 0 > /sys/class/power_supply/wireless/current_max
bash: /sys/class/power_supply/wireless/current_max: Permission denied
# chmod +w /sys/class/power_supply/wireless/current_max
# echo 0 > /sys/class/power_supply/wireless/current_max
bash: echo: write error: Invalid argument
# cat /sys/class/power_supply/wireless/current_max
704000
# echo 704000 > /sys/class/power_supply/wireless/current_max
bash: echo: write error: Invalid argument

Nothing has any effect on the charging current.

For USB charging, even though usb/current_max is writable (after chmod) and remembers value, this has no effect on charging current:

# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 21:18 ac/current_max = 1472000
-r--r--r-- 1 root root 4096 Oct 1 21:16 usb/current_max = 500000
-rw-r--r-- 1 root root 4096 Oct 1 21:18 wireless/current_max = 704000
# echo 0 > /sys/class/power_supply/usb/current_max
bash: /sys/class/power_supply/usb/current_max: Permission denied
# chmod +w /sys/class/power_supply/usb/current_max
# echo 0 > /sys/class/power_supply/usb/current_max
# cat /sys/class/power_supply/usb/current_max
0
# echo 0 > /sys/class/power_supply/ac/current_max
# cat /sys/class/power_supply/ac/current_max
1472000
# echo 0 > /sys/class/power_supply/wireless/current_max
bash: echo: write error: Invalid argument
# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 21:23 ac/current_max = 1472000
-rw-r--r-- 1 root root 4096 Oct 1 21:22 usb/current_max = 0
-rw-r--r-- 1 root root 4096 Oct 1 21:23 wireless/current_max = 704000

On wireless charging, no value sticks or can be written:

# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 21:23 ac/current_max = 704000
-rw-r--r-- 1 root root 4096 Oct 1 21:22 usb/current_max = 0
-rw-r--r-- 1 root root 4096 Oct 1 21:23 wireless/current_max = 704000
# echo 0 > /sys/class/power_supply/ac/current_max
# cat /sys/class/power_supply/ac/current_max
704000
(failed reverse-i-search)`eho ': cat /sys/class/power_supply/ac/curr^Ct_max
# echo 0 > /sys/class/power_supply/wireless/current_max
bash: echo: write error: Invalid argument
# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 21:27 ac/current_max = 704000
-rw-r--r-- 1 root root 4096 Oct 1 21:22 usb/current_max = 0
-rw-r--r-- 1 root root 4096 Oct 1 21:27 wireless/current_max = 704000

Nexus 5X (LOS 14.1 Nougat 7.1)

Neither usb/current_max nor usb-parallel/current_max can be written to:

# echo 0 > /sys/class/power_supply/usb/current_max
bash: /sys/class/power_supply/usb/current_max: Permission denied
# echo 0 > /sys/class/power_supply/usb-parallel/current_max
bash: /sys/class/power_supply/usb-parallel/current_max: Permission denied

They can be written to after a chmod.

When on AC power, the charging can be limited successfully by writing 0 to usb/current_max:

d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-r--r--r-- 1 root root 4096 Oct 1 18:36 usb-parallel/current_max = 2000
-r--r--r-- 1 root root 4096 Feb 10 1970 usb/current_max = 3000000
# echo 0 > /sys/class/power_supply/usb/current_max
# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-r--r--r-- 1 root root 4096 Oct 1 18:36 usb-parallel/current_max = 0
-rw-r--r-- 1 root root 4096 Oct 1 18:37 usb/current_max = 0

The phone stops charging too.

On USB Power, the files can be written to, but if 0 is written to usb-parallel/current_max, then a very high default is set by the kernel:

USB Charger is connected:

# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 18:40 usb-parallel/current_max = 2000
-rw-r--r-- 1 root root 4096 Oct 1 18:38 usb/current_max = 500000

AccuBattery reports a 300mA charge current. Then I try to tweak values:

# echo 0 > /sys/class/power_supply/usb/current_max
# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 18:40 usb-parallel/current_max = 2000
-rw-r--r-- 1 root root 4096 Oct 1 18:46 usb/current_max = 0

AccuBattery now reports -80mA (dis-)charging current, so it seems to work.

If I try to tweak usb-parallel:

# echo 0 > /sys/class/power_supply/usb-parallel/current_max
# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 18:51 usb-parallel/current_max = 100000
-rw-r--r-- 1 root root 4096 Oct 1 18:50 usb/current_max = 0

Despite that I set 0, the value now reads 100000 and AccuBattery reports a charging current of 20mA, higher than before usb-parallel was messed with.

OnePlus 5 running OOS 4.5 Nougat 7.1

When on an AC charger, writing to dc/current_max works but has no effect:

# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 2 12:47 dc/current_max = 500000
-rw-r--r-- 1 root root 4096 Oct 2 12:48 usb/current_max = -22
# echo 0 > /sys/class/power_supply/dc/current_max
# cat /sys/class/power_supply/dc/current_max
0

But writing to usb/current_max shuts down the charging:

# echo 0 > /sys/class/power_supply/usb/current_max
# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 2 12:48 dc/current_max = 0
-rw-r--r-- 1 root root 4096 Oct 2 12:50 usb/current_max = 0

And charging stops. To restore charging, writing the initial values works but has no effect:

# echo 500000 > /sys/class/power_supply/dc/current_max
# echo -22 > /sys/class/power_supply/usb/current_max
# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 2 12:53 dc/current_max = 500000
-rw-r--r-- 1 root root 4096 Oct 2 12:53 usb/current_max = -22

Nope, the phone is not back charging.

However if you write a high enough value to usb/current_max, it starts charging again:

# echo 250000 > /sys/class/power_supply/usb/current_max

...and the charging rate oscillate around 50mA

# echo 250000 > /sys/class/power_supply/usb/current_max

...and the charging rate goes up to 350mA

# echo 2500000 > /sys/class/power_supply/usb/current_max

...and the charging rate is back at full speed.

When plugged on a USB charger, changing dc/current_max has no effect:

# echo 0 > /sys/class/power_supply/dc/current_max
# cat /sys/class/power_supply/dc/current_max
0

...but charging keeps going.

Again, altering usb/current_max works:

# echo 0 > /sys/class/power_supply/usb/current_max
# cat /sys/class/power_supply/usb/current_max
0

... and the charging stops.

Interestingly, the charger cannot be scaled when on USB, but using the full current value allows us to resume charging:

# echo 250000 > /sys/class/power_supply/usb/current_max
bash: echo: write error: Invalid argument
# echo 300000 > /sys/class/power_supply/usb/current_max
bash: echo: write error: Invalid argument
# echo 499000 > /sys/class/power_supply/usb/current_max
bash: echo: write error: Invalid argument
# echo 500000 > /sys/class/power_supply/usb/current_max

Samsung Galaxy Tab S2 (SM-T813 gts210vewifi) running LOS 14.1 Nougat 7.1

msm-usb/current_max is always 0, I haven't attempted to mess with it.

When on AC Charger, sm5703-charger/current_max cannot be changed (and need to be chmoded to be written to):

# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 20:33 msm-usb/current_max = 0
-r--r--r-- 1 root root 4096 Oct 1 20:33 sm5703-charger/current_max = 2100
# echo 0 > /sys/class/power_supply/sm5703-charger/current_max
bash: /sys/class/power_supply/sm5703-charger/current_max: Permission denied
# chmod 644 /sys/class/power_supply/sm5703-charger/current_max
# echo 0 > /sys/class/power_supply/sm5703-charger/current_max
bash: echo: write error: Invalid argument
# echo 1 > /sys/class/power_supply/sm5703-charger/current_max
bash: echo: write error: Invalid argument
# echo 500 > /sys/class/power_supply/sm5703-charger/current_max
bash: echo: write error: Invalid argument
# echo 2000 > /sys/class/power_supply/sm5703-charger/current_max
bash: echo: write error: Invalid argument
# echo 2100 > /sys/class/power_supply/sm5703-charger/current_max
bash: echo: write error: Invalid argument

Same story when the tablet is plugged into a USB Charger:

# d=/sys/class/power_supply; for i in $(cd $d && find */ -name current_max) ; do printf '%-96s = %s\n' "$(cd $d && ls -l $i)" "$(cat $d/$i)"; done
-rw-r--r-- 1 root root 4096 Oct 1 20:51 msm-usb/current_max = 0
-rw-r--r-- 1 root root 4096 Oct 1 20:33 sm5703-charger/current_max = 450
# echo 0 > /sys/class/power_supply/sm5703-charger/current_max
bash: echo: write error: Invalid argument
# echo 450 > /sys/class/power_supply/sm5703-charger/current_max
bash: echo: write error: Invalid argument

Summary

On the devices tested, all running some variants of Nougat 7.1 (OOS or LOS):

The Nexus 4 can only have its charging current lowered to 500mA when charging over USB. Over AC or Wireless charging, the charging current cannot be controlled. As the device lacks a proper charging_enabled sysfs file, the old MCS doesn't work either.

The Nexus 5's battery current cannot be controlled in any charging mode. Also, as the device lacks a proper charging_enabled sysfs file, the old MCS doesn't work either.

The Nexus 5X's battery current seems to be controllable but there's some weirdness in the values automatically set (echoing a value in a sysfs file can alter the other). The old MCS works fine there through /sys/class/power_supply/battery/charging_enabled.

On the OnePlus 5, the current can be scaled at will when charging on AC, but on USB, it can either be 0mA or 500mA or over (it cannot scale between 1-500mA). The old MCS works fine there through /sys/class/power_supply/battery/charging_enabled.

The Galaxy Tab S2's current cannot be controlled in any charging mode. The old MCS works fine through /sys/class/power_supply/battery/batt_slate_mode.

The tally:

Old MCS (battery switch): works on 3/5 devices: Nexus 5X, Galaxy Tab S2, OnePlus 5; doesn't work on the 2 oldest devices: Nexus 4 & 5.

New MCS (current switch): works on 1.8/5 devices (fully on OnePlus 5, works on Nexus 4 w/USB but not on AC or Wireless, works weirdly on Nexus 5X, doesn't work on Nexus 5 nor Galaxy Tab S2).

That was a long post, I hope it's useful.