I need to find a way to (using an Android application) programmatically connect and disconnect an Android device from a host.
I am using a Galaxy Nexus. My goal is to keep everything as close to stock as possible, though I have already enabled verbose debug messages in the kernel and in order to view them have enabled root access on the phone to access /proc/kmsg
(and the shell command dmesg
).
I am certain that there is a way to leverage root access to do what I need to do, but all of my attempts have lead to nix.
- Mess with
/proc/bus/usb
- Mess with
/dev/bus/usb
- Change between MTP/PTP (unable to do programatically)
- Making the Android USB gadget driver into a module <- ???
I am going to try to figure out how to do the last object on the list, as then I would be able to rmmod
and insmod
the resulting *.ko
in my application and that would connect and disconnect the phone. I am unsure of the feasibility of this option though.