Is it possible to disable a USB port through the Android SDK or NDK?
Is t开发者_Python百科here a way of disabling a USB port on an Android enabled device using the Android SDK or NDK?
This applies to a USB accessories port (i.e. not for ADB)... If you have a rooted device, you can try this as it worked for me...find the file indicating devices authorized for your port and clear it as follows (Note the path will be specific to your system so it may take a bit of searching - I have a platform based on Freescale HW & BSP) You can try this from a shell session but ultimately it can be done from a script or shell commands executed from within an application
$su
#cd /sys/devices/platform/fsl-ehci.0/usb1/
#echo 0 > authorized
If you need to re-enable, just do
#cd /sys/devices/platform/fsl-ehci.0/usb1/
#echo 1 > authorized
Settings changed in this way worked for me to enable & disable both a USB keyboard and a mass storage device (thumb drive). NOTE: What you set this way may not persist through a reboot or power cycle (it did not in my case) so plan accordingly.
精彩评论