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

Commit 0d9d5ef1 authored by Josh Gao's avatar Josh Gao Committed by android-build-merger
Browse files

Merge "adb: make `adb reconnect` perform a USB reset."

am: 3b25a17a

Change-Id: Ic952e10f80684614a0f9da795c730bb52be5a259
parents d2060b77 3b25a17a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1114,7 +1114,7 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty
                return true;
            }
            return false;
        });
        }, true);
        if (!response.empty()) {
            response.resize(response.size() - 1);
        }
@@ -1229,7 +1229,7 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty
        std::string response;
        atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &response, true);
        if (t != nullptr) {
            kick_transport(t);
            kick_transport(t, true);
            response =
                    "reconnecting " + t->serial_name() + " [" + t->connection_state_name() + "]\n";
        }
+5 −0
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@ int usb_close(usb_handle* h) {
                               : native::usb_close(reinterpret_cast<native::usb_handle*>(h));
}

void usb_reset(usb_handle* h) {
    should_use_libusb() ? libusb::usb_reset(reinterpret_cast<libusb::usb_handle*>(h))
                        : native::usb_reset(reinterpret_cast<native::usb_handle*>(h));
}

void usb_kick(usb_handle* h) {
    should_use_libusb() ? libusb::usb_kick(reinterpret_cast<libusb::usb_handle*>(h))
                        : native::usb_kick(reinterpret_cast<native::usb_handle*>(h));
+5 −0
Original line number Diff line number Diff line
@@ -622,6 +622,11 @@ int usb_close(usb_handle* h) {
    return 0;
}

void usb_reset(usb_handle* h) {
    libusb_reset_device(h->device_handle);
    usb_kick(h);
}

void usb_kick(usb_handle* h) {
    h->Close();
}
+5 −0
Original line number Diff line number Diff line
@@ -458,6 +458,11 @@ int usb_read(usb_handle *h, void *_data, int len)
    return orig_len - len;
}

void usb_reset(usb_handle* h) {
    ioctl(h->fd, USBDEVFS_RESET);
    usb_kick(h);
}

void usb_kick(usb_handle* h) {
    std::lock_guard<std::mutex> lock(h->mutex);
    D("[ kicking %p (fd = %d) ]", h, h->fd);
+7 −0
Original line number Diff line number Diff line
@@ -556,6 +556,13 @@ int usb_close(usb_handle *handle)
    return 0;
}

void usb_reset(usb_handle* handle) {
    if (!handle->dead) {
        (*handle->interface)->USBDeviceReEnumerate(handle->interface, 0);
    }
    usb_kick(handle);
}

static void usb_kick_locked(usb_handle *handle)
{
    LOG(INFO) << "Kicking handle";
Loading