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

Commit 638420ef authored by Yabin Cui's avatar Yabin Cui
Browse files

adb: close ep0 on disconnection.

adbd on device kicks the usb connection when usb IO fails. But to notify
adb on host to reconnect it, adbd needs to close ep0 to reset the usb
connection. Otherwise, adb on host cann't connect the device unless the
usb cable is reconnected or adb host server is restarted.

This can be tested by using `adb reconnect device` command.

Bug: 25935458

Change-Id: I80979d6029e60b9cfd218f7b9b5201810238ec07
(cherry picked from commit 69e97e4b)
parent 06951757
Loading
Loading
Loading
Loading
+24 −25
Original line number Diff line number Diff line
@@ -400,7 +400,6 @@ static bool init_functionfs(struct usb_handle *h)
    v2_descriptor.os_header = os_desc_header;
    v2_descriptor.os_desc = os_desc_compat;

    if (h->control < 0) { // might have already done this before
    D("OPENING %s", USB_FFS_ADB_EP0);
    h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR);
    if (h->control < 0) {
@@ -429,7 +428,6 @@ static bool init_functionfs(struct usb_handle *h)
        D("[ %s: writing strings failed: errno=%d]", USB_FFS_ADB_EP0, errno);
        goto err;
    }
    }

    h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR);
    if (h->bulk_out < 0) {
@@ -556,6 +554,7 @@ static void usb_ffs_close(usb_handle *h) {
    h->kicked = false;
    adb_close(h->bulk_out);
    adb_close(h->bulk_in);
    adb_close(h->control);
    // Notify usb_adb_open_thread to open a new connection.
    adb_mutex_lock(&h->lock);
    h->open_new_connection = true;