Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0301b321 authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge changes from topics 'adb_thread', 'adb_loopback'

* changes:
  adb: statically link libbase into the tests.
  adb: kill adb_thread_{create, join, detach, exit}.
  adb: don't try to resolve 'localhost'
parents e771b69e 47330e21
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -81,12 +81,14 @@ LIBADB_windows_CFLAGS := \

LIBADB_darwin_SRC_FILES := \
    sysdeps_unix.cpp \
    sysdeps/posix/network.cpp \
    client/usb_dispatch.cpp \
    client/usb_libusb.cpp \
    client/usb_osx.cpp \

LIBADB_linux_SRC_FILES := \
    sysdeps_unix.cpp \
    sysdeps/posix/network.cpp \
    client/usb_dispatch.cpp \
    client/usb_libusb.cpp \
    client/usb_linux.cpp \
@@ -123,6 +125,7 @@ LOCAL_SRC_FILES := \
    $(LIBADB_SRC_FILES) \
    adbd_auth.cpp \
    jdwp_service.cpp \
    sysdeps/posix/network.cpp \

LOCAL_SANITIZE := $(adb_target_sanitize)

@@ -217,9 +220,9 @@ LOCAL_SRC_FILES_linux := $(LIBADB_TEST_linux_SRCS)
LOCAL_SRC_FILES_darwin := $(LIBADB_TEST_darwin_SRCS)
LOCAL_SRC_FILES_windows := $(LIBADB_TEST_windows_SRCS)
LOCAL_SANITIZE := $(adb_host_sanitize)
LOCAL_SHARED_LIBRARIES := libbase
LOCAL_STATIC_LIBRARIES := \
    libadb \
    libbase \
    libcrypto_utils \
    libcrypto \
    libcutils \
+2 −4
Original line number Diff line number Diff line
@@ -574,7 +574,7 @@ static void register_device(const char* dev_name, const char* dev_path,
    register_usb_transport(done_usb, serial.c_str(), dev_path, done_usb->writeable);
}

static void device_poll_thread(void*) {
static void device_poll_thread() {
    adb_thread_setname("device poll");
    D("Created device thread");
    while (true) {
@@ -593,8 +593,6 @@ void usb_init() {
    actions.sa_handler = [](int) {};
    sigaction(SIGALRM, &actions, nullptr);

    if (!adb_thread_create(device_poll_thread, nullptr)) {
        fatal_errno("cannot create device_poll thread");
    }
    std::thread(device_poll_thread).detach();
}
} // namespace native
+2 −4
Original line number Diff line number Diff line
@@ -405,7 +405,7 @@ err_get_num_ep:

std::mutex& operate_device_lock = *new std::mutex();

static void RunLoopThread(void* unused) {
static void RunLoopThread() {
    adb_thread_setname("RunLoop");

    VLOG(USB) << "RunLoopThread started";
@@ -436,9 +436,7 @@ void usb_init() {

        usb_inited_flag = false;

        if (!adb_thread_create(RunLoopThread, nullptr)) {
            fatal_errno("cannot create RunLoop thread");
        }
        std::thread(RunLoopThread).detach();

        // Wait for initialization to finish
        while (!usb_inited_flag) {
+5 −9
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ static void kick_devices();

/// Entry point for thread that polls (every second) for new usb interfaces.
/// This routine calls find_devices in infinite loop.
static void device_poll_thread(void*);
static void device_poll_thread();

/// Initializes this module
void usb_init();
@@ -174,7 +174,7 @@ int register_new_device(usb_handle* handle) {
  return 1;
}

void device_poll_thread(void*) {
void device_poll_thread() {
  adb_thread_setname("Device Poll");
  D("Created device thread");

@@ -203,7 +203,7 @@ static LRESULT CALLBACK _power_window_proc(HWND hwnd, UINT uMsg, WPARAM wParam,
  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}

static void _power_notification_thread(void*) {
static void _power_notification_thread() {
  // This uses a thread with its own window message pump to get power
  // notifications. If adb runs from a non-interactive service account, this
  // might not work (not sure). If that happens to not work, we could use
@@ -258,12 +258,8 @@ static void _power_notification_thread(void*) {
}

void usb_init() {
  if (!adb_thread_create(device_poll_thread, nullptr)) {
    fatal_errno("cannot create device poll thread");
  }
  if (!adb_thread_create(_power_notification_thread, nullptr)) {
    fatal_errno("cannot create power notification thread");
  }
  std::thread(device_poll_thread).detach();
  std::thread(_power_notification_thread).detach();
}

usb_handle* do_usb_open(const wchar_t* interface_name) {
+2 −7
Original line number Diff line number Diff line
@@ -655,13 +655,8 @@ static int RemoteShell(bool use_shell_protocol, const std::string& type_arg,
#endif

    // TODO: combine read_and_dump with stdin_read_thread to make life simpler?
    int exit_code = 1;
    if (!adb_thread_create(stdin_read_thread_loop, args)) {
        PLOG(ERROR) << "error starting stdin read thread";
        delete args;
    } else {
        exit_code = read_and_dump(fd, use_shell_protocol);
    }
    std::thread(stdin_read_thread_loop, args).detach();
    int exit_code = read_and_dump(fd, use_shell_protocol);

    // TODO: properly exit stdin_read_thread_loop and close |fd|.

Loading