代码见 /system/core/adb
enable logs:
adb_trace.h
+#define VLOG_IS_ON(TAG) 1
add more logs:
#if defined(_WIN32)
#if ADB_HOST
#if !ADB_HOST
D("readx: fd=%d wanted=%zu", fd, len);
user key 'C:\Users\28847867\.android\adbkey
windows PC: adb.exe; linux PC: adb
Phone: adbd
adb devices
同adb server建立socket, new socket, connect,
send("host:version"), 首先得到版本信息,判断是否需要重启adb server.
然后send("host:devices"), then read response.
adb_commandline() in commandline.cpp called in main() in client/main.cpp
std::string query = android::base::StringPrintf("host:%s%s", argv[0], listopt);
printf("List of devices attached\n");
return adb_query_command("host:devices")
adb_query_command("host:devices")
adb_query("host:devices")
adb_connect("host:devices")
ReadProtocolString()
adb_connect("host:devices")
int fd = _adb_connect("host:version", error); //根据version,判断是否要重启server
fd = _adb_connect("host:devices", error);
_adb_connect("host:devices", error);
network_connect() new socket, connect() in sysdeps_win32.cpp
SendProtocolString(fd, service))
SendProtocolString(fd, service))
WriteFdFmt()
WriteFdExactly(int fd, const void* buf, size_t len)
adb_write() in sysdeps_win32.cpp
_fh_socket_write
send
Reference:
android adb源码分析
http://blog.csdn.net/xgbing/article/details/52058390
http://blog.csdn.net/xgbing/article/details/52059755http://blog.csdn.net/xgbing/article/details/52065277
http://blog.csdn.net/xgbing/article/details/52075667
http://blog.csdn.net/xgbing/article/details/52096880
http://blog.csdn.net/xiaojsj111/article/details/18599653