Android11上,通过命令行访问adb的时候增加密码。
修改以后,直接访问adb会报错,需要使用
详细修改如下:
此处主要通过重置accept_shell的值,让adb断开以后需要重新输入密码进行访问
diff --git a/system/core/adb/adb.cpp b/system/core/adb/adb.cpp index c3e9731a30..990dec445b 100644 --- a/system/core/adb/adb.cpp +++ b/system/core/adb/adb.cpp @@ -100,6 +100,11 @@ apacket* get_apacket(void) return p; } + +#if !ADB_HOST +int accept_shell; +#endif + void put_apacket(apacket *p) { delete p; @@ -110,6 +115,9 @@ void handle_online(atransport *t) D("adb: online"); t->online = 1; t->SetConnectionEstablished(true); + #if !ADB_HOST + accept_shell = 0; + #endif } void handle_offline(atransport *t) @@ -126,6 +134,9 @@ void handle_offline(atransport *t) // Close the associated usb t->online = 0; + #if !ADB_HOST + accept_shell = 0; + #endif // This is necessary to avoid a race condition that occurred when a transport closes // while a client socket is still active. close_all_sockets(t)
访问密码通过读取property(persist.otg.passwd)的值获取, 默认为admin
diff --git a/system/core/adb/services.cpp b/system/core/adb/services.cpp index 853d658976..c1544f6ac6 100644 --- a/system/core/adb/services.cpp +++ b/system/core/adb/services.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -74,9 +75,41 @@ unique_fd create_service_thread(const char* service_name, std::function= 0) { + close_on_exec(ret); + } + } + return ret; + } +#endif if (is_socket_spec(name)) { std::string error; if (!socket_spec_connect(&ret, name, nullptr, nullptr, &error)) {
上一篇:word的空格叫什么
下一篇:qq提醒音乐叫什么名字