I am trying to search if there is a way to disable android device usb port, software level mainly. So users can still charge android device but cannot communicate with PC anymore.
I got some clues in link1. But it looks there is not an easy way for this.
Android OS is a Linux based OS. So I am wondering if there is a config file in Android OS that allows root users to disable usb port, like files under path /etc in Linux OS.
EDIT: Use this command in android terminal emulator. Root priveleges required, but you can put a password on Superuser so that no one else can undo this or edit the script:
echo 0 > /sys/devices/virtual/android_usb/android0/enable
or...
su -c 'echo 0 > /sys/devices/virtual/android_usb/android0/enable'
To automate this, you need to make a script and put it in /system/etc/init.d, let's say /system/etc/init.d/usb_off:
#!/system/bin/sh
echo 0 > /sys/devices/virtual/android_usb/android0/enable
Then make sure it's executable with:
chmod +x /system/etc/init.d/usb_off
You can also try this, but it's reported not to work. Execute these in the command line via Android Terminal Emulator:
setprop persist.sys.usb.config ''
setprop sys.usb.config ''
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With