Disable USB charging
I just tried and found that you need to modify a file:
sys/class/power_supply/usb/device/charge

its default content is '1' which means 'enable charging'
you need to set it to '0' to 'disable charging'

$ su

$ echo 0 &gt; /sys/class/power_supply/usb/device/charge


I tested on Nexus 4 and it's working successfully.