Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

For some reasons not related to the battery life, I need to disable the battery charging when a USB host is connected to my phone (a rooted Nexus 4). Taking a look around on the internet (link1, link2), it looks like I should modify a system file. I have found a series of interesting files located in /sys/class/power_supply/battery and /sys/class/power_supply/usb, that could be the right ones to be modified in order to achieve the usb charging disabling (e.g. /sys/class/power_supply/usb/present 0/1).

Has anyone tried something like that (control the usb charging via software and modify such system files)? Which is the best way to modify those system files? Should I use the adb shell or another tool?

I tried the "root explore" app in order to modify those files, however when I modified a file (after changing its permissions), it was automatically kept back to its original value.

share|improve this question
While this may or may not contribute to the question, I'm curious as to why you want to disable USB charging. –  dotVezz Oct 11 '13 at 12:39
What I have here is something more similar to an embedded system: a phone (USB ACCESSORY) and a piece of hardware (USB HOST), connected through USB. The phone battery supplies the attached hardware through a specific connection (Vdd). However, the USB HOST is supposed to supply (or charge) the phone through the VBUS line of the USB. What I want to avoid is a loop of charge between phone and attached hardware. Despite the attached hardware is the HOST, it is the Android phone that supplies the whole system. Hope my explanation was clear to you. –  STiLLeN Oct 11 '13 at 12:55
/sys is a virtual file system where the kernel exposes knobs and switches to alter and look up kernel configuration. You can't change the file permissions. I guess your nexus phone is unlocked and rooted. The charging circuit is probably based on a Maxim chip that may be configured. There are altered kernels available which allow overriding of the detection for power charging. The reverse should also be possible. You may need to patch and recompile the kernel though. –  ce4 Oct 11 '13 at 13:19
Franco Kernel for the nexus 4 allows fast charging, sources are available. maybe you can have a look at it and figure out how to switch it off: github.com/franciscofranco –  ce4 Oct 11 '13 at 13:33
Here's the driver: github.com/franciscofranco/mako/blob/nightlies-4.3-JWR/drivers/… –  ce4 Oct 11 '13 at 22:06
show 1 more comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.