From 4995a2a54d8d1f549938de3b713d7ed92aaf681c Mon Sep 17 00:00:00 2001 From: lixin <3531982712@qq.com> Date: Tue, 22 Apr 2025 14:11:41 +0800 Subject: [PATCH] feat(adbd): adbd always tries to configure usb gadget in host mode. --- packages/modules/adb/daemon/usb.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/modules/adb/daemon/usb.cpp b/packages/modules/adb/daemon/usb.cpp index f9e085fbae5..71d13d8f502 100644 --- a/packages/modules/adb/daemon/usb.cpp +++ b/packages/modules/adb/daemon/usb.cpp @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include "adb_unique_fd.h" #include "adb_utils.h" @@ -262,6 +264,13 @@ struct UsbFfsConnection : public Connection { bool enabled = false; bool running = true; while (running) { + std::string mode; + + if (android::base::ReadFileToString("/sys/kernel/debug/usb/23000000.usb/mode", &mode)) { + mode = android::base::Trim(mode); + if (mode == "host") continue; + } + adb_pollfd pfd[2] = { { .fd = control_fd_.get(), .events = POLLIN, .revents = 0 }, { .fd = monitor_event_fd_.get(), .events = POLLIN, .revents = 0 }, -- 2.17.1