通过网络使用adb
2015-12-03 17:26
639 查看
通过网络使用adb
2010-03-17 14:13
在adb的说明文档中提到:
“An ADB transport models a connection between the ADB server and one device
or emulator. There are currently two kinds of transports:
- USB transports, for physical devices through USB
- Local transports, for emulators running on the host, connected to
the server through TCP”
大意是说,在物理设备上,adb是通过USB连接到设备上的,而在模拟器上,adb是通过TCP协议连接到设备上的。实际上在物理设备上,也可以让adb通过TCP协议来连接设备(当然前提条件是你的设备要有网口)。首先看一下下面这段源代码,出自system/core/adb/adb.c,第921行:
/* for the device, start the usb transport if the
** android usb device exists and "service.adb.tcp"
** is not set, otherwise start the network transport.
*/
property_get("service.adb.tcp.port", value, "0");
if (sscanf(value, "%d", &port) == 1 && port > 0) {
// listen on TCP port specified by service.adb.tcp.port property
local_init(port);
} else if (access("/dev/android_adb", F_OK) == 0) {
// listen on USB
usb_init();
} else {
// listen on default port
local_init(ADB_LOCAL_TRANSPORT_PORT);
}
分析上述代码可以发现,在adbd启动时首先检查是否设置了service.adb.tcp.port,如果设置了,就是使用TCP作为连接方式;如果没设置,就去检查是否有adb的USB设备(dev/android_adb),如果有就用USB作为连接方式;如果没有USB设备,则还是用TCP作为连接方式。
因此只需要在启动adbd之前设置service.adb.tcp.port,就可以让adbd选则TCP模式,也就可以通过网络来连接adb了。这需要修改init.rc文件。如果不想修改,也可以在系统启动之后,在控制台上执行下列命令:
#stop adbd
#set service.adb.tcp.port 5555
#start adbd
这样就可以在主机上通过下列命令来连接设备了:
adb connetc <ip-of-device>:5555
相关文章推荐
- HttpClient进行POST请求(HTTPS方式)
- 关于http get和post的相关资料
- HTTP学习笔记(2)HTTP报文
- TCP/IP 端口大全
- 网络层—ICMP
- 详细介绍了 TCP/IP 协议族中的各个协议在 OSI 模型中的分布
- HTTP网络通信小结
- Java Web开发之获取HttpBody
- VirtualBox虚拟机网络环境解析和搭建-NAT、桥接、Host-Only、Internal、端口映射
- Android 网络连接的变更
- 应对恶劣网络环境,为php-curl设置超时限制,防止服务器卡死
- HTTP文件断点上传
- tcpdump 抓包过滤
- Java Web开发之httpServletRequest获取客户端真实ip
- 实现https双向认证,并去除commonName的校验
- 弱网络下的游戏服务器设计
- Xcode7 网络访问限制
- Xcode7 https -- http
- Android网络编程的基础1
- 网络设备和OSI参考模型关系