The use case here is deploying the Nexus S as part of an enterprise platform. Users of the phones should not be able to enable USB debugging -- but administrators should be, with a password or something similar.开发者_运维问答
It seems like this should be possible by deploying custom versions of Settings.apk=com.android.settings and/or SettingsProvider.apk=com.android.providers.settings? Are there any lighter-weight options?
Not sure if this is a development-related question. Anyway, here is how I would do it:
- Get Settings.apk from /system/app
- Rename Settings.apk to Settings.zip
- Now get ./res/xml/development_prefs.xml (an example of this xml is here)
- You need to convert this development_prefs.xml from binary to text (you'll need to figure that out yourself, I've never tried it myself).
- Remove preference item with key "enable_adb".
- Convert development_prefs.xml back to binary format.
- Copy it into Settings.zip archive
- Rename Settings.zip to Settings.apk
- Copy this modified Settings.zip to your phone
One additional note: there are number of folder of format "xml-[locale]", like "xml-ru", "xml-zh-TW" and so on. You should modify all development_prefs.xml from those folder too. Or as another option, you can remove all thos folders altogether, provided you don't need multilingual support.
And if your admins would need to enable adb, they could copy original Settings.apk over to the phone. Or you can write small .apk yourself with this feature alone and just install it side-by-side with modified Settings.apk.
精彩评论