How can I disable Android USB debugging programmatically

独自空忆成欢 提交于 2019-12-29 08:52:23

问题


There is a bug on some Samsung Android Phones causing USB-debugging to automatically be turned on if the USB is plugged in. This is obviously a security issue. I want to write a program which will disable USB debugging so that I can start it whenever usb-plug is inserted. Any ideas on how to do this?


回答1:


It seems to be impossible. I think I must use Settings.System with ADB_ENABLED, but ADB_ENABLED is a Secure-System-Setting which cannot be changed by a normal application. :-(

On the other hand, there is the permission android.permission.WRITE_SECURE_SETTINGS, so it looks like I can alter it. Can I get it on a rooted phone?

If someone has an idea on how to fix this security issue, it would be great.




回答2:


I don't think it is a security issue.

First, it is the responsibility of a developer to only make debug messages available that do not compromise his application in the later.

Secondly, debug messages that are used for development should probably have another debug level than for production.

Third, if your application exposes data via adb that compromisses your application, maybe there's something wrong in the app design in the beginning?

Fourth: It is not recommended to toggle settings that the user should be able to configure. I would hate to see manything I configured go on and off by starting an app. Of course, you mentioned the Bug with Samsung. But I think they should be able to fix this.

Regards, Chris



来源:https://stackoverflow.com/questions/5564870/how-can-i-disable-android-usb-debugging-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!