如何禁用Android设备的USB端口 [英] How to disable android device usb port

查看:2138
本文介绍了如何禁用Android设备的USB端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试搜索是否有一种方法可以禁用android设备的usb端口(主要是软件级别).因此,用户仍然可以为android设备充电,但无法再与PC通信.

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.

link1 中提供了一些线索.但这似乎没有简单的方法.

I got some clues in link1. But it looks there is not an easy way for this.

Android OS是基于Linux的操作系统.因此,我想知道Android OS中是否存在一个配置文件,该文件允许root用户禁用USB端口,例如Linux OS中路径/etc下的文件.

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.

推荐答案

在android终端模拟器中使用此命令.需要root特权,但是您可以在超级用户上输入密码,以便其他任何人都不能撤消该特权或编辑脚本:

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

或...

su -c 'echo 0 > /sys/devices/virtual/android_usb/android0/enable'

要使其自动化,您需要制作一个脚本并将其放在/system/etc/init.d中,假设/system/etc/init.d/usb_off:

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


您也可以尝试执行此操作,但是据报道它不起作用.通过Android Terminal Emulator在命令行中执行这些操作:


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 ''

这篇关于如何禁用Android设备的USB端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆