ADB的默认最大会话数是16。如果需要更多的会话,可以通过修改ADB的源代码来自定义最大会话数。以下是具体步骤:
下载ADB源代码
打开adb.c文件,定位到MAX_ADB_CLIENTS常量
更改MAX_ADB_CLIENTS的值为所需的最大会话数
重新编译ADB源代码
使用新的ADB二进制文件
代码示例:
#define DEFAULT_ADB_PORT 5037 #define MAX_ADB_CLIENTS 16 //修改这里的值为所需的最大会话数 #define SERVER_SOCKET_PORT 0x4e21
struct adb_demon_startup_params { int is_daemon; int server_port; int happy_eyeballs_connect_timeout_ms; int happy_eyeballs_connect_wait_ms; }; ...... int main(int argc, char **argv) { std::unique_ptrbase::CommandLine command_line = base::CommandLine::ForCurrentProcess(); base::InitLogging(command_line->GetSwitchValuePath("log-file"));
adb_demon_startup_params params = {};
int ret = parse_args(argc, argv, ¶ms);
if (ret != 0) {
printf("Usage: %s [-d] [-P port_number] [--connect-timeout CONNECT_TIMEOUT_MS] [--connect-wait CONNECT_WAIT_MS]\n", argv[0]);
return ret;
}
adb_main(params.is_daemon, params.server_port, params.happy_eyeballs_connect_timeout_ms, params.happy_eyeballs_connect_wait_ms);
return 0;
}