adb的相关控制
在android 4.0 之后,adb 的控制统一使用了persist.sys.usb.config来控制,而这个persist.sys.usb.config 中的adb是根据ro.debuggable = 1 or 0 来设置,1 就是开启adb, 0 即关闭adb debug.
有两个地方影响
- build/tools/post_process_props.py
def mangle_build_prop(prop_list):
# If ro.debuggable is 1, then enable adb on USB by default
# (this is for userdebug builds)
if prop_list.get_value("ro.debuggable") == "1":
val = prop_list.get_value("persist.sys.usb.config")
if "adb" not in val:
if val == "":
val = "adb"
else:
val = val + ",adb"
prop_list.put("persist.sys.usb.config", val)
# UsbDeviceManager expects a value here. If it doesn't get it, it will
# default to "adb". That might not the right policy there, but it's better
# to be explicit.
if not prop_list.get_value("persist.sys.usb.config"):
prop_list.put("persist.sys.usb.config", "none")
在system.prop中添加的会被post_process_props.py中的覆盖,build.prop中有显示
# Value overridden by post_process_props.py. Original value: mtp
persist.sys.usb.config=mtp,adb
- system/core/init/property_service.cpp
static void update_sys_usb_config() {
bool is_debuggable = android::base::GetBoolProperty("ro.debuggable", false);
std::string config = android::base::GetProperty("persist.sys.usb.config", "");
// b/150130503, add (config == "none") condition here to prevent appending
// ",adb" if "none" is explicitly defined in default prop.
if (config.empty() || config &