Delete virtual_usb_manager and USB support

This functionality was never enabled for crosvm.

Test: Build and run locally
Bug: 146087651
Change-Id: Ifeae71ec11beb3654b201fd431ab1498e980ea31
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index f776042..400a686 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -98,17 +98,15 @@
 DEFINE_int32(vnc_server_port, GetPerInstanceDefault(6444),
              "The port on which the vnc server should listen");
 DEFINE_string(adb_mode, "vsock_half_tunnel",
-              "Mode for ADB connection. Can be 'usb' for USB forwarding, "
-              "'tunnel' for a TCP connection tunneled through VSoC, "
+              "Mode for ADB connection."
               "'vsock_tunnel' for a TCP connection tunneled through vsock, "
               "'native_vsock' for a  direct connection to the guest ADB over "
               "vsock, 'vsock_half_tunnel' for a TCP connection forwarded to "
               "the guest ADB server, or a comma separated list of types as in "
-              "'usb,tunnel'");
+              "'native_vsock,vsock_half_tunnel'");
 DEFINE_bool(run_adb_connector, true,
             "Maintain adb connection by sending 'adb connect' commands to the "
             "server. Only relevant with -adb_mode=tunnel or vsock_tunnel");
-DEFINE_int32(vhci_port, GetPerInstanceDefault(0), "VHCI port to use for usb");
 DEFINE_string(wifi_tap_name, GetPerInstanceDefault("cvd-wtap-"),
               "The name of the tap interface to use for wifi");
 DEFINE_int32(vsock_guest_cid,
@@ -291,14 +289,6 @@
     }
   }
 
-  if (tmp_config_obj.adb_mode().count(vsoc::AdbMode::Usb) > 0) {
-    tmp_config_obj.set_usb_v1_socket_name(
-        tmp_config_obj.PerInstanceInternalPath("usb-v1"));
-    tmp_config_obj.set_vhci_port(FLAGS_vhci_port);
-    tmp_config_obj.set_usb_ip_socket_name(
-        tmp_config_obj.PerInstanceInternalPath("usb-ip"));
-  }
-
   tmp_config_obj.set_deprecated_boot_completed(FLAGS_deprecated_boot_completed);
   tmp_config_obj.set_logcat_receiver_binary(
       vsoc::DefaultHostArtifactsPath("bin/logcat_receiver"));
@@ -330,8 +320,6 @@
   tmp_config_obj.set_run_adb_connector(FLAGS_run_adb_connector);
   tmp_config_obj.set_adb_connector_binary(
       vsoc::DefaultHostArtifactsPath("bin/adb_connector"));
-  tmp_config_obj.set_virtual_usb_manager_binary(
-      vsoc::DefaultHostArtifactsPath("bin/virtual_usb_manager"));
   tmp_config_obj.set_socket_vsock_proxy_binary(
       vsoc::DefaultHostArtifactsPath("bin/socket_vsock_proxy"));
   tmp_config_obj.set_run_as_daemon(FLAGS_daemon);
@@ -340,10 +328,6 @@
   tmp_config_obj.set_blank_data_image_mb(FLAGS_blank_data_image_mb);
   tmp_config_obj.set_blank_data_image_fmt(FLAGS_blank_data_image_fmt);
 
-  if(tmp_config_obj.adb_mode().count(vsoc::AdbMode::Usb) == 0) {
-    tmp_config_obj.disable_usb_adb();
-  }
-
   tmp_config_obj.set_logcat_mode(FLAGS_logcat_mode);
 
   tmp_config_obj.set_enable_tombstone_receiver(FLAGS_enable_tombstone_receiver);
diff --git a/host/commands/run_cvd/launch.cc b/host/commands/run_cvd/launch.cc
index 227984d..44e32fa 100644
--- a/host/commands/run_cvd/launch.cc
+++ b/host/commands/run_cvd/launch.cc
@@ -53,10 +53,6 @@
       && AdbModeEnabled(config, vsoc::AdbMode::NativeVsock);
 }
 
-bool AdbUsbEnabled(const vsoc::CuttlefishConfig& config) {
-  return AdbModeEnabled(config, vsoc::AdbMode::Usb);
-}
-
 cvd::OnSocketReadyCb GetOnSubprocessExitCallback(
     const vsoc::CuttlefishConfig& config) {
   if (config.restart_subprocesses()) {
@@ -183,25 +179,6 @@
   return { socket->VsockServerPort() };
 }
 
-void LaunchUsbServerIfEnabled(const vsoc::CuttlefishConfig& config,
-                              cvd::ProcessMonitor* process_monitor) {
-  if (!AdbUsbEnabled(config)) {
-    return;
-  }
-  auto socket_name = config.usb_v1_socket_name();
-  auto usb_v1_server = cvd::SharedFD::SocketLocalServer(
-      socket_name.c_str(), false, SOCK_STREAM, 0666);
-  if (!usb_v1_server->IsOpen()) {
-    LOG(ERROR) << "Unable to create USB v1 server socket: "
-               << usb_v1_server->StrError();
-    std::exit(cvd::RunnerExitCodes::kUsbV1SocketError);
-  }
-  cvd::Command usb_server(config.virtual_usb_manager_binary());
-  usb_server.AddParameter("-usb_v1_fd=", usb_v1_server);
-  process_monitor->StartSubprocess(std::move(usb_server),
-                                   GetOnSubprocessExitCallback(config));
-}
-
 cvd::SharedFD CreateUnixVncInputServer(const std::string& path) {
   auto server = cvd::SharedFD::SocketLocalServer(path.c_str(), false, SOCK_STREAM, 0666);
   if (!server->IsOpen()) {
diff --git a/host/commands/run_cvd/launch.h b/host/commands/run_cvd/launch.h
index efd4966..95455ef 100644
--- a/host/commands/run_cvd/launch.h
+++ b/host/commands/run_cvd/launch.h
@@ -13,8 +13,6 @@
     const vsoc::CuttlefishConfig& config,
     cvd::ProcessMonitor* process_monitor,
     unsigned int number_of_event_pipes);
-void LaunchUsbServerIfEnabled(const vsoc::CuttlefishConfig& config,
-                              cvd::ProcessMonitor* process_monitor);
 void LaunchAdbConnectorIfEnabled(cvd::ProcessMonitor* process_monitor,
                                  const vsoc::CuttlefishConfig& config,
                                  cvd::SharedFD adbd_events_pipe);
diff --git a/host/commands/run_cvd/main.cc b/host/commands/run_cvd/main.cc
index c4972bc..e352393 100644
--- a/host/commands/run_cvd/main.cc
+++ b/host/commands/run_cvd/main.cc
@@ -159,13 +159,7 @@
   }
   std::string config_env = "export CUTTLEFISH_PER_INSTANCE_PATH=\"" +
                            config.PerInstancePath(".") + "\"\n";
-  config_env += "export ANDROID_SERIAL=";
-  if (config.adb_mode().count(vsoc::AdbMode::Usb) > 0) {
-    config_env += config.serial_number();
-  } else {
-    config_env += config.adb_ip_and_port();
-  }
-  config_env += "\n";
+  config_env += "export ANDROID_SERIAL=" + config.adb_ip_and_port() + "\n";
   env->Write(config_env.c_str(), config_env.size());
   return true;
 }
@@ -413,8 +407,6 @@
   auto tombstone_server = LaunchTombstoneReceiverIfEnabled(*config, &process_monitor);
   auto tombstone_kernel_args = KernelCommandLineFromTombstone(tombstone_server);
 
-  LaunchUsbServerIfEnabled(*config, &process_monitor);
-
   // The vnc server needs to be launched after the ivserver because it connects
   // to it when using qemu. It needs to launch before the VMM because it serves
   // on several sockets (input devices, vsock frame server) when using crosvm.
diff --git a/host/commands/virtual_usb_manager/Android.bp b/host/commands/virtual_usb_manager/Android.bp
deleted file mode 100644
index 6669b8c..0000000
--- a/host/commands/virtual_usb_manager/Android.bp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-cc_binary_host {
-    name: "virtual_usb_manager",
-    srcs: [
-        "main.cc",
-        "vadb/usb_cmd_attach.cpp",
-        "vadb/usb_cmd_control_transfer.cpp",
-        "vadb/usb_cmd_data_transfer.cpp",
-        "vadb/usb_cmd_device_list.cpp",
-        "vadb/usb_cmd_heartbeat.cpp",
-        "vadb/virtual_adb_client.cpp",
-        "vadb/virtual_adb_server.cpp",
-        "usbip/client.cpp",
-        "usbip/device_pool.cpp",
-        "usbip/messages.cpp",
-        "usbip/server.cpp",
-        "usbip/vhci_instrument.cpp",
-    ],
-    header_libs: [
-        "cuttlefish_glog",
-    ],
-    shared_libs: [
-        "libcuttlefish_fs",
-        "libcuttlefish_utils",
-        "libbase",
-    ],
-    static_libs: [
-        "libcuttlefish_host_config",
-        "libgflags",
-        "libjsoncpp",
-    ],
-    defaults: ["cuttlefish_host_only"],
-}
diff --git a/host/commands/virtual_usb_manager/main.cc b/host/commands/virtual_usb_manager/main.cc
deleted file mode 100644
index 39fd556..0000000
--- a/host/commands/virtual_usb_manager/main.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-#include <thread>
-
-#include <gflags/gflags.h>
-#include <glog/logging.h>
-
-#include "common/libs/fs/shared_fd.h"
-#include "common/libs/fs/shared_select.h"
-#include "host/libs/config/cuttlefish_config.h"
-#include "host/commands/virtual_usb_manager/usbip/server.h"
-#include "host/commands/virtual_usb_manager/vadb/virtual_adb_server.h"
-
-DEFINE_int32(
-    usb_v1_fd, -1,
-    "A file descriptor pointing to the USB v1 open socket or -1 to create it");
-
-int main(int argc, char** argv) {
-  ::android::base::InitLogging(argv, android::base::StderrLogger);
-  google::ParseCommandLineFlags(&argc, &argv, true);
-
-  auto config = vsoc::CuttlefishConfig::Get();
-  if (!config) {
-    LOG(ERROR) << "Unable to get config object";
-    return 1;
-  }
-
-  cvd::SharedFD usb_v1_server;
-
-  if (FLAGS_usb_v1_fd < 0) {
-    auto socket_name = config->usb_v1_socket_name();
-    LOG(INFO) << "Starting server at " << socket_name;
-    usb_v1_server = cvd::SharedFD::SocketLocalServer(socket_name.c_str(), false,
-                                                     SOCK_STREAM, 0666);
-  } else {
-    usb_v1_server = cvd::SharedFD::Dup(FLAGS_usb_v1_fd);
-  }
-
-  if (!usb_v1_server->IsOpen()) {
-    LOG(ERROR) << "Error openning USB v1 server: " << usb_v1_server->StrError();
-    return 2;
-  }
-
-  vadb::VirtualADBServer adb_{usb_v1_server, config->vhci_port(),
-                              config->usb_ip_socket_name()};
-  vadb::usbip::Server usbip_{config->usb_ip_socket_name(), adb_.Pool()};
-
-  CHECK(usbip_.Init()) << "Could not start USB/IP server";
-
-  for (;;) {
-    cvd::SharedFDSet fd_read;
-    fd_read.Zero();
-
-    adb_.BeforeSelect(&fd_read);
-    usbip_.BeforeSelect(&fd_read);
-
-    int ret = cvd::Select(&fd_read, nullptr, nullptr, nullptr);
-    if (ret <= 0) continue;
-
-    adb_.AfterSelect(fd_read);
-    usbip_.AfterSelect(fd_read);
-  }
-
-  return 0;
-}
diff --git a/host/commands/virtual_usb_manager/usbip/Android.bp b/host/commands/virtual_usb_manager/usbip/Android.bp
deleted file mode 100644
index 8a52b90..0000000
--- a/host/commands/virtual_usb_manager/usbip/Android.bp
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-cc_library_host_static {
-    name: "libusbip",
-    srcs: [
-        "client.cpp",
-        "device_pool.cpp",
-        "messages.cpp",
-        "server.cpp",
-        "vhci_instrument.cpp",
-    ],
-    header_libs: [
-        "cuttlefish_glog",
-    ],
-    shared_libs: [
-        "libcuttlefish_fs",
-        "libbase",
-    ],
-    static_libs: [
-        "libgflags",
-    ],
-    defaults: ["cuttlefish_host_only"],
-}
diff --git a/host/commands/virtual_usb_manager/usbip/README.md b/host/commands/virtual_usb_manager/usbip/README.md
deleted file mode 100644
index e652352..0000000
--- a/host/commands/virtual_usb_manager/usbip/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# USB/IP server library
-
-This folder contains set of classes and structures that constitute basic USB/IP 
-server.
-
-Protocol used in this library is defined as part of
-[Linux kernel documentation](https://www.kernel.org/doc/Documentation/usb/usbip_protocol.txt).
-
-## Structure
-
-### [`vadb::usbip::Device`](./device.h)[](#Device)
-
-Structure describing individual device accessible over USB/IP protocol.
-
-### [`vadb::usbip::DevicePool`](./device_pool.h)[](#DevicePool)
-
-DevicePool holds a set of [Devices](#Device) that can be enumerated and
-accessed by clients of this Server.
-
-### [`vadb::usbip::Server`](./server.h)
-
-Purpose of this class is to start a new listening socket and accept incoming
-USB/IP connections & requests.
-
-### [`vadb::usbip::Client`](./client.h)
-
-Client class represents individual USB/IP connection. Client enables remote
-USB/IP client to enumerate and access devices registered in
-[DevicePool](#DevicePool).
-
-### [`USB/IP Messages`](./messages.h)
-
-This file contains structures and enum values defined by the USB/IP protocol.
-All definitions found there have been collected from
-[Linux kernel documentation](https://www.kernel.org/doc/Documentation/usb/usbip_protocol.txt)
-.
diff --git a/host/commands/virtual_usb_manager/usbip/client.cpp b/host/commands/virtual_usb_manager/usbip/client.cpp
deleted file mode 100644
index 50ea9f8..0000000
--- a/host/commands/virtual_usb_manager/usbip/client.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "host/commands/virtual_usb_manager/usbip/client.h"
-
-#include <arpa/inet.h>
-
-#include <glog/logging.h>
-#include <iostream>
-
-#include "host/commands/virtual_usb_manager/usbip/device.h"
-#include "host/commands/virtual_usb_manager/usbip/messages.h"
-
-namespace vadb {
-namespace usbip {
-
-// NetToHost and HostToNet are used to reduce risk of copy/paste errors and to
-// provide uniform method of converting messages between different endian types.
-namespace {
-
-uint32_t NetToHost(uint32_t t) { return ntohl(t); }
-
-Command NetToHost(Command t) { return static_cast<Command>(ntohl(t)); }
-
-Direction NetToHost(Direction t) { return static_cast<Direction>(ntohl(t)); }
-
-uint32_t NetToHost(uint16_t t) { return ntohs(t); }
-
-CmdHeader NetToHost(const CmdHeader& t) {
-  CmdHeader rval = t;
-  rval.command = NetToHost(t.command);
-  rval.seq_num = NetToHost(t.seq_num);
-  rval.bus_num = NetToHost(t.bus_num);
-  rval.dev_num = NetToHost(t.dev_num);
-  rval.direction = NetToHost(t.direction);
-  rval.endpoint = NetToHost(t.endpoint);
-  return rval;
-}
-
-CmdReqSubmit NetToHost(const CmdReqSubmit& t) {
-  CmdReqSubmit rval = t;
-  rval.transfer_flags = NetToHost(t.transfer_flags);
-  rval.transfer_buffer_length = NetToHost(t.transfer_buffer_length);
-  rval.start_frame = NetToHost(t.start_frame);
-  rval.number_of_packets = NetToHost(t.number_of_packets);
-  rval.deadline_interval = NetToHost(t.deadline_interval);
-  return rval;
-}
-
-CmdReqUnlink NetToHost(const CmdReqUnlink& t) {
-  CmdReqUnlink rval = t;
-  rval.seq_num = NetToHost(t.seq_num);
-  return rval;
-}
-
-uint32_t HostToNet(uint32_t t) { return htonl(t); }
-
-Command HostToNet(const Command t) { return static_cast<Command>(htonl(t)); }
-
-Direction HostToNet(Direction t) { return static_cast<Direction>(htonl(t)); }
-
-uint16_t HostToNet(uint16_t t) { return htons(t); }
-
-CmdHeader HostToNet(const CmdHeader& t) {
-  CmdHeader rval = t;
-  rval.command = HostToNet(t.command);
-  rval.seq_num = HostToNet(t.seq_num);
-  rval.bus_num = HostToNet(t.bus_num);
-  rval.dev_num = HostToNet(t.dev_num);
-  rval.direction = HostToNet(t.direction);
-  rval.endpoint = HostToNet(t.endpoint);
-  return rval;
-}
-
-CmdRepSubmit HostToNet(const CmdRepSubmit& t) {
-  CmdRepSubmit rval = t;
-  rval.status = HostToNet(t.status);
-  rval.actual_length = HostToNet(t.actual_length);
-  rval.start_frame = HostToNet(t.start_frame);
-  rval.number_of_packets = HostToNet(t.number_of_packets);
-  rval.error_count = HostToNet(t.error_count);
-  return rval;
-}
-
-CmdRepUnlink HostToNet(const CmdRepUnlink& t) {
-  CmdRepUnlink rval = t;
-  rval.status = HostToNet(t.status);
-  return rval;
-}
-
-// Converts data to network order and sends it to the USB/IP client.
-// Returns true, if message was sent successfully.
-template <typename T>
-bool SendUSBIPMsg(const cvd::SharedFD& fd, const T& data) {
-  T net = HostToNet(data);
-  return fd->Send(&net, sizeof(T), MSG_NOSIGNAL) == sizeof(T);
-}
-
-// Receive message from USB/IP client.
-// After message is received, it's updated to match host endian.
-// Returns true, if message was received successfully.
-template <typename T>
-bool RecvUSBIPMsg(const cvd::SharedFD& fd, T* data) {
-  T net;
-  bool res = fd->Recv(&net, sizeof(T), MSG_NOSIGNAL) == sizeof(T);
-  if (res) {
-    *data = NetToHost(net);
-  }
-  return res;
-}
-
-}  // namespace
-
-void Client::BeforeSelect(cvd::SharedFDSet* fd_read) const {
-  fd_read->Set(fd_);
-}
-
-bool Client::AfterSelect(const cvd::SharedFDSet& fd_read) {
-  if (fd_read.IsSet(fd_)) return HandleIncomingMessage();
-  return true;
-}
-
-// Handle incoming COMMAND.
-//
-// Read next CMD from client channel.
-// Returns false, if connection should be dropped.
-bool Client::HandleIncomingMessage() {
-  CmdHeader hdr;
-  if (!RecvUSBIPMsg(fd_, &hdr)) {
-    LOG(ERROR) << "Could not read command header: " << fd_->StrError();
-    return false;
-  }
-
-  // And the protocol, again.
-  switch (hdr.command) {
-    case kUsbIpCmdReqSubmit:
-      return HandleSubmitCmd(hdr);
-
-    case kUsbIpCmdReqUnlink:
-      return HandleUnlinkCmd(hdr);
-
-    default:
-      LOG(ERROR) << "Unsupported command requested: " << hdr.command;
-      return false;
-  }
-}
-
-// Handle incoming SUBMIT COMMAND.
-//
-// Execute command on specified USB device.
-// Returns false, if connection should be dropped.
-bool Client::HandleSubmitCmd(const CmdHeader& cmd) {
-  CmdReqSubmit req;
-  if (!RecvUSBIPMsg(fd_, &req)) {
-    LOG(ERROR) << "Could not read submit command: " << fd_->StrError();
-    return false;
-  }
-
-  uint32_t seq_num = cmd.seq_num;
-
-  // Reserve buffer for data in or out.
-  std::vector<uint8_t> payload;
-  int payload_length = req.transfer_buffer_length;
-  payload.resize(payload_length);
-
-  bool is_host_to_device = cmd.direction == kUsbIpDirectionOut;
-  // Control requests are quite easy to detect; if setup is all '0's, then we're
-  // doing a data transfer, otherwise it's a control transfer.
-  // We only check for cmd and type fields here, as combination 0/0 of these
-  // fields is already invalid (cmd == GET_STATUS, type = WRITE).
-  bool is_control_request = !(req.setup.cmd == 0 && req.setup.type == 0);
-
-  // Find requested device and execute command.
-  auto device = pool_.GetDevice({cmd.bus_num, cmd.dev_num});
-  if (device) {
-    // Read data to be sent to device, if specified.
-    if (is_host_to_device && payload_length) {
-      size_t got = 0;
-      // Make sure we read everything.
-      while (got < payload.size()) {
-        auto read =
-            fd_->Recv(&payload[got], payload.size() - got, MSG_NOSIGNAL);
-        if (fd_->GetErrno() != 0) {
-          LOG(ERROR) << "Client disconnected: " << fd_->StrError();
-          return false;
-        } else if (!read) {
-          LOG(ERROR) << "Short read; client likely disconnected.";
-          return false;
-        }
-        got += read;
-      }
-    }
-
-    // If setup structure of request is initialized then we need to execute
-    // control transfer. Otherwise, this is a plain data exchange.
-    bool send_success = false;
-    if (is_control_request) {
-      send_success = device->handle_control_transfer(
-          req.setup, req.deadline_interval, std::move(payload),
-          [this, seq_num, is_host_to_device](bool is_success,
-                                             std::vector<uint8_t> data) {
-            HandleAsyncDataReady(seq_num, is_success, is_host_to_device,
-                                 std::move(data));
-          });
-    } else {
-      send_success = device->handle_data_transfer(
-          cmd.endpoint, is_host_to_device, req.deadline_interval,
-          std::move(payload),
-          [this, seq_num, is_host_to_device](bool is_success,
-                                             std::vector<uint8_t> data) {
-            HandleAsyncDataReady(seq_num, is_success, is_host_to_device,
-                                 std::move(data));
-          });
-    }
-
-    // Simply fail if couldn't execute command.
-    if (!send_success) {
-      HandleAsyncDataReady(seq_num, false, is_host_to_device,
-                           std::vector<uint8_t>());
-    }
-  }
-  return true;
-}
-
-void Client::HandleAsyncDataReady(uint32_t seq_num, bool is_success,
-                                  bool is_host_to_device,
-                                  std::vector<uint8_t> data) {
-  // Response template.
-  // - in header, host doesn't care about anything else except for command type
-  //   and sequence number.
-  // - in body, report status == !OK unless we completed everything
-  //   successfully.
-  CmdHeader rephdr{};
-  rephdr.command = kUsbIpCmdRepSubmit;
-  rephdr.seq_num = seq_num;
-
-  CmdRepSubmit rep{};
-  rep.status = is_success ? 0 : 1;
-  rep.actual_length = data.size();
-
-  // Data out.
-  if (!SendUSBIPMsg(fd_, rephdr)) {
-    LOG(ERROR) << "Failed to send response header: " << fd_->StrError();
-    return;
-  }
-
-  if (!SendUSBIPMsg(fd_, rep)) {
-    LOG(ERROR) << "Failed to send response body: " << fd_->StrError();
-    return;
-  }
-
-  if (!is_host_to_device && data.size() > 0) {
-    if (static_cast<size_t>(
-            fd_->Send(data.data(), data.size(), MSG_NOSIGNAL)) != data.size()) {
-      LOG(ERROR) << "Failed to send response payload: " << fd_->StrError();
-      return;
-    }
-  }
-}
-
-// Handle incoming UNLINK COMMAND.
-//
-// Unlink removes command specified via seq_num from a list of commands to be
-// executed.
-// We don't schedule commands for execution, so technically every UNLINK will
-// come in late.
-// Returns false, if connection should be dropped.
-bool Client::HandleUnlinkCmd(const CmdHeader& cmd) {
-  CmdReqUnlink req;
-  if (!RecvUSBIPMsg(fd_, &req)) {
-    LOG(ERROR) << "Could not read unlink command: " << fd_->StrError();
-    return false;
-  }
-  LOG(INFO) << "Client requested to unlink previously submitted command: "
-            << req.seq_num;
-
-  CmdHeader rephdr{};
-  rephdr.command = kUsbIpCmdRepUnlink;
-  rephdr.seq_num = cmd.seq_num;
-
-  // Technically we do not schedule commands for execution, so we cannot
-  // de-queue commands, either. Indicate this by sending status != ok.
-  CmdRepUnlink rep;
-  rep.status = 1;
-
-  if (!SendUSBIPMsg(fd_, rephdr)) {
-    LOG(ERROR) << "Could not send unlink command header: " << fd_->StrError();
-    return false;
-  }
-
-  if (!SendUSBIPMsg(fd_, rep)) {
-    LOG(ERROR) << "Could not send unlink command data: " << fd_->StrError();
-    return false;
-  }
-  return true;
-}
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/client.h b/host/commands/virtual_usb_manager/usbip/client.h
deleted file mode 100644
index 5e48f21..0000000
--- a/host/commands/virtual_usb_manager/usbip/client.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "common/libs/fs/shared_fd.h"
-#include "common/libs/fs/shared_select.h"
-#include "host/commands/virtual_usb_manager/usbip/device_pool.h"
-#include "host/commands/virtual_usb_manager/usbip/messages.h"
-
-namespace vadb {
-namespace usbip {
-
-// Represents USB/IP client, or individual connection to our USB/IP server.
-// Multiple clients are allowed, even if practically we anticipate only one
-// connection at the time.
-class Client final {
- public:
-  Client(const DevicePool& pool, const cvd::SharedFD& fd)
-      : pool_(pool), fd_(fd) {}
-
-  ~Client() {}
-
-  // BeforeSelect is Called right before Select() to populate interesting
-  // SharedFDs.
-  void BeforeSelect(cvd::SharedFDSet* fd_read) const;
-
-  // AfterSelect is Called right after Select() to detect and respond to changes
-  // on affected SharedFDs.
-  // Return value indicates whether this client is still valid.
-  bool AfterSelect(const cvd::SharedFDSet& fd_read);
-
- private:
-  // Respond to message from remote client.
-  // Returns false, if client violated protocol or disconnected, indicating,
-  // that this instance should no longer be used.
-  bool HandleIncomingMessage();
-
-  // Execute command on USB device.
-  // Returns false, if connection should be dropped.
-  bool HandleSubmitCmd(const CmdHeader& hdr);
-
-  // HandleAsyncDataReady is called asynchronously once previously submitted
-  // data transfer (control or bulk) has completed (or failed).
-  void HandleAsyncDataReady(uint32_t seq_num, bool is_success,
-                            bool is_host_to_device, std::vector<uint8_t> data);
-
-  // Unlink previously submitted message from device queue.
-  // Returns false, if connection should be dropped.
-  bool HandleUnlinkCmd(const CmdHeader& hdr);
-
-  const DevicePool& pool_;
-  cvd::SharedFD fd_;
-
-  Client(const Client&) = delete;
-  Client& operator=(const Client&) = delete;
-};
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/device.h b/host/commands/virtual_usb_manager/usbip/device.h
deleted file mode 100644
index 7af1ccc..0000000
--- a/host/commands/virtual_usb_manager/usbip/device.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <cstdint>
-#include <functional>
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "host/commands/virtual_usb_manager/usbip/messages.h"
-
-namespace vadb {
-namespace usbip {
-
-// The device descriptor of a USB device represents a USB device that is
-// available for import.
-class Device {
- public:
-  // AsyncTransferReadyCB specifies a signature of a function that will be
-  // called upon transfer completion (whether successful or failed). Parameters
-  // supplied to the function are:
-  // - operation status, indicated by boolean flag (true = success),
-  // - vector containing transferred data (and actual size).
-  using AsyncTransferReadyCB = std::function<void(bool, std::vector<uint8_t>)>;
-
-  // Interface provides minimal description of device's interface.
-  struct Interface {
-    uint8_t iface_class;
-    uint8_t iface_subclass;
-    uint8_t iface_protocol;
-  };
-
-  // vendor_id and product_id identify device manufacturer and type.
-  // dev_version describes device version (as BCD).
-  uint16_t vendor_id;
-  uint16_t product_id;
-  uint16_t dev_version;
-
-  // Class, Subclass and Protocol define device type.
-  uint8_t dev_class;
-  uint8_t dev_subclass;
-  uint8_t dev_protocol;
-
-  // Speed indicates device speed (see libusb_speed).
-  uint8_t speed;
-
-  // ConfigurationsCount and ConfigurationNumber describe total number of device
-  // configurations and currently activated device configuration.
-  size_t configurations_count;
-  size_t configuration_number;
-
-  // Interfaces returns a collection of device interfaces.
-  std::vector<Interface> interfaces;
-
-  // Attach request handler.
-  std::function<bool()> handle_attach;
-
-  // Device control request dispatcher.
-  std::function<bool(const CmdRequest& request, uint32_t deadline,
-                     std::vector<uint8_t> data, AsyncTransferReadyCB callback)>
-      handle_control_transfer;
-
-  // Device  data request dispatcher.
-  std::function<bool(uint8_t endpoint, bool is_host_to_device,
-                     uint32_t deadline, std::vector<uint8_t> data,
-                     AsyncTransferReadyCB callback)>
-      handle_data_transfer;
-};
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/device_pool.cpp b/host/commands/virtual_usb_manager/usbip/device_pool.cpp
deleted file mode 100644
index ecd3e8e..0000000
--- a/host/commands/virtual_usb_manager/usbip/device_pool.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "host/commands/virtual_usb_manager/usbip/device_pool.h"
-
-#include <glog/logging.h>
-
-namespace vadb {
-namespace usbip {
-
-void DevicePool::AddDevice(BusDevNumber bdn, std::unique_ptr<Device> device) {
-  devices_[bdn] = std::move(device);
-}
-
-Device* DevicePool::GetDevice(BusDevNumber bus_id) const {
-  auto iter = devices_.find(bus_id);
-  if (iter == devices_.end()) return nullptr;
-  return iter->second.get();
-}
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/device_pool.h b/host/commands/virtual_usb_manager/usbip/device_pool.h
deleted file mode 100644
index f6988c4..0000000
--- a/host/commands/virtual_usb_manager/usbip/device_pool.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <map>
-#include <string>
-
-#include "host/commands/virtual_usb_manager/usbip/device.h"
-
-namespace vadb {
-namespace usbip {
-// Container for all virtual USB/IP devices.
-// Stores devices by virtual BUS ID.
-class DevicePool {
- public:
-  // BusDevNumber is a pair uniquely identifying bus and device.
-  struct BusDevNumber {
-    uint16_t bus_number;
-    uint16_t dev_number;
-
-    bool operator<(BusDevNumber other) const {
-      return (bus_number << 16 | dev_number) <
-             (other.bus_number << 16 | other.dev_number);
-    }
-  };
-
-  // Internal container type.
-  using MapType = std::map<BusDevNumber, std::unique_ptr<Device>>;
-
-  DevicePool() = default;
-  virtual ~DevicePool() = default;
-
-  // Add new device associated with virtual BUS ID.
-  void AddDevice(BusDevNumber bus_id, std::unique_ptr<Device> device);
-
-  // Get device associated with supplied virtual bus/device number.
-  Device* GetDevice(BusDevNumber bus_dev_num) const;
-
-  // Get total number of USB/IP devices.
-  size_t Size() const { return devices_.size(); }
-
-  MapType::const_iterator begin() const { return devices_.cbegin(); }
-  MapType::const_iterator end() const { return devices_.cend(); }
-
- private:
-  MapType devices_;
-
-  DevicePool(const DevicePool&) = delete;
-  DevicePool& operator=(const DevicePool&) = delete;
-};
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/messages.cpp b/host/commands/virtual_usb_manager/usbip/messages.cpp
deleted file mode 100644
index 9de7c26..0000000
--- a/host/commands/virtual_usb_manager/usbip/messages.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "host/commands/virtual_usb_manager/usbip/messages.h"
-
-#include <netinet/in.h>
-#include <iostream>
-
-#include <glog/logging.h>
-
-namespace vadb {
-namespace usbip {
-namespace {
-// Basic sanity checking.
-// We're using CmdHeader + CmdReq/Rep in case any of the fields is moved between
-// structures.
-constexpr int kUsbIpCmdLength = 48;
-
-static_assert(sizeof(CmdHeader) + sizeof(CmdReqSubmit) == kUsbIpCmdLength,
-              "USB/IP command + header must be exactly 48 bytes.");
-static_assert(sizeof(CmdHeader) + sizeof(CmdRepSubmit) == kUsbIpCmdLength,
-              "USB/IP command + header must be exactly 48 bytes.");
-static_assert(sizeof(CmdHeader) + sizeof(CmdReqUnlink) == kUsbIpCmdLength,
-              "USB/IP command + header must be exactly 48 bytes.");
-static_assert(sizeof(CmdHeader) + sizeof(CmdRepUnlink) == kUsbIpCmdLength,
-              "USB/IP command + header must be exactly 48 bytes.");
-}  // namespace
-
-std::ostream& operator<<(std::ostream& out, const CmdHeader& header) {
-  out << "CmdHeader\n";
-  out << "\t\tcmd:\t" << header.command << '\n';
-  out << "\t\tseq#:\t" << header.seq_num << '\n';
-  out << "\t\tbus#:\t0x" << header.bus_num << '\n';
-  out << "\t\tdev#:\t0x" << header.dev_num << '\n';
-  out << "\t\tdir:\t" << (header.direction ? "in" : "out") << '\n';
-  out << "\t\tendpt:\t" << header.endpoint << "\n";
-  return out;
-}
-
-std::ostream& operator<<(std::ostream& out, const CmdRequest& setup) {
-  out << "Request\n";
-  out << "\t\t\ttype:\t" << std::hex << int(setup.type) << '\n';
-  out << "\t\t\treq:\t" << int(setup.cmd) << std::dec << '\n';
-  out << "\t\t\tval:\t" << setup.value << '\n';
-  out << "\t\t\tidx:\t" << setup.index << '\n';
-  out << "\t\t\tlen:\t" << setup.length << '\n';
-  return out;
-}
-
-std::ostream& operator<<(std::ostream& out, const CmdReqSubmit& submit) {
-  out << "CmdReqSubmit\n";
-  out << "\t\ttr_flg:\t" << std::hex << submit.transfer_flags << std::dec
-      << '\n';
-  out << "\t\ttr_len:\t" << submit.transfer_buffer_length << '\n';
-  out << "\t\tstart:\t" << submit.start_frame << '\n';
-  out << "\t\tpktcnt:\t" << submit.number_of_packets << '\n';
-  out << "\t\tttl:\t" << submit.deadline_interval << '\n';
-  out << "\t\tsetup:\t" << submit.setup << '\n';
-  return out;
-}
-
-std::ostream& operator<<(std::ostream& out, const CmdRepSubmit& submit) {
-  out << "CmdRepSubmit\n";
-  out << "\t\tstatus:\t" << submit.status << '\n';
-  out << "\t\tlen:\t" << submit.actual_length << '\n';
-  out << "\t\tstart:\t" << submit.start_frame << '\n';
-  out << "\t\tpktcnt:\t" << submit.number_of_packets << '\n';
-  out << "\t\terrors:\t" << submit.error_count << '\n';
-  out << "\t\tsetup:\t" << submit.setup << '\n';
-  return out;
-}
-
-std::ostream& operator<<(std::ostream& out, const CmdReqUnlink& unlink) {
-  out << "CmdReqUnlink\n";
-  out << "\t\tseq#:\t" << unlink.seq_num << '\n';
-  return out;
-}
-
-std::ostream& operator<<(std::ostream& out, const CmdRepUnlink& unlink) {
-  out << "CmdRepUnlink\n";
-  out << "\t\tstatus:\t" << unlink.status << '\n';
-  return out;
-}
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/messages.h b/host/commands/virtual_usb_manager/usbip/messages.h
deleted file mode 100644
index 8594465..0000000
--- a/host/commands/virtual_usb_manager/usbip/messages.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <glog/logging.h>
-#include <stdint.h>
-
-#include "common/libs/fs/shared_fd.h"
-
-// Requests and constants below are defined in kernel documentation file:
-// https://www.kernel.org/doc/Documentation/usb/usbip_protocol.txt
-namespace vadb {
-namespace usbip {
-
-////////////////////////////////////////////////////////////////////////////////
-// COMMANDS
-////////////////////////////////////////////////////////////////////////////////
-
-// Command numbers. Commands are valid only once USB device is attached.
-enum Command : uint32_t {
-  kUsbIpCmdReqSubmit = 1,  // Submit request
-  kUsbIpCmdReqUnlink = 2,  // Unlink request
-  kUsbIpCmdRepSubmit = 3,  // Submit response
-  kUsbIpCmdRepUnlink = 4,  // Unlink response
-};
-
-// Direction of data flow.
-enum Direction : uint32_t {
-  kUsbIpDirectionOut = 0,
-  kUsbIpDirectionIn = 1,
-};
-
-// Setup structure is explained in great detail here:
-// - http://www.beyondlogic.org/usbnutshell/usb6.shtml
-// - http://www.usbmadesimple.co.uk/ums_4.htm
-struct CmdRequest {
-  uint8_t type;
-  uint8_t cmd;
-  uint16_t value;
-  uint16_t index;
-  uint16_t length;
-} __attribute__((packed));
-
-// CmdHeader precedes any command request or response body.
-struct CmdHeader {
-  Command command;
-  uint32_t seq_num;
-  uint16_t bus_num;
-  uint16_t dev_num;
-  Direction direction;
-  uint32_t endpoint;  // valid values: 0-15
-} __attribute__((packed));
-
-// Command data for submitting an USB request.
-struct CmdReqSubmit {
-  uint32_t transfer_flags;
-  uint32_t transfer_buffer_length;
-  uint32_t start_frame;
-  uint32_t number_of_packets;
-  uint32_t deadline_interval;
-  CmdRequest setup;
-} __attribute__((packed));
-
-// Command response for submitting an USB request.
-struct CmdRepSubmit {
-  uint32_t status;  // 0 = success.
-  uint32_t actual_length;
-  uint32_t start_frame;
-  uint32_t number_of_packets;
-  uint32_t error_count;
-  CmdRequest setup;
-} __attribute__((packed));
-
-// Unlink USB request.
-struct CmdReqUnlink {
-  uint32_t seq_num;
-  uint32_t reserved[6];
-} __attribute__((packed));
-
-// Unlink USB response.
-struct CmdRepUnlink {
-  uint32_t status;
-  uint32_t reserved[6];
-} __attribute__((packed));
-
-// Diagnostics.
-std::ostream& operator<<(std::ostream& out, const CmdHeader& header);
-std::ostream& operator<<(std::ostream& out, const CmdReqSubmit& data);
-std::ostream& operator<<(std::ostream& out, const CmdRepSubmit& data);
-std::ostream& operator<<(std::ostream& out, const CmdReqUnlink& data);
-std::ostream& operator<<(std::ostream& out, const CmdRepUnlink& data);
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/server.cpp b/host/commands/virtual_usb_manager/usbip/server.cpp
deleted file mode 100644
index ef71b72..0000000
--- a/host/commands/virtual_usb_manager/usbip/server.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "host/commands/virtual_usb_manager/usbip/server.h"
-
-#include <glog/logging.h>
-#include <netinet/in.h>
-#include "common/libs/fs/shared_select.h"
-
-using cvd::SharedFD;
-
-namespace vadb {
-namespace usbip {
-Server::Server(const std::string& name, const DevicePool& devices)
-    : name_{name}, device_pool_{devices} {}
-
-bool Server::Init() { return CreateServerSocket(); }
-
-// Open new listening server socket.
-// Returns false, if listening socket could not be created.
-bool Server::CreateServerSocket() {
-  LOG(INFO) << "Starting server socket: " << name_;
-
-  server_ = SharedFD::SocketLocalServer(name_.c_str(), true, SOCK_STREAM, 0700);
-  if (!server_->IsOpen()) {
-    LOG(ERROR) << "Could not create socket: " << server_->StrError();
-    return false;
-  }
-  return true;
-}
-
-void Server::BeforeSelect(cvd::SharedFDSet* fd_read) const {
-  fd_read->Set(server_);
-  for (const auto& client : clients_) client.BeforeSelect(fd_read);
-}
-
-void Server::AfterSelect(const cvd::SharedFDSet& fd_read) {
-  if (fd_read.IsSet(server_)) HandleIncomingConnection();
-
-  for (auto iter = clients_.begin(); iter != clients_.end();) {
-    if (!iter->AfterSelect(fd_read)) {
-      // If client conversation failed, hang up.
-      iter = clients_.erase(iter);
-      continue;
-    }
-    ++iter;
-  }
-}
-
-// Accept new USB/IP connection. Add it to client pool.
-void Server::HandleIncomingConnection() {
-  SharedFD client = SharedFD::Accept(*server_, nullptr, nullptr);
-  if (!client->IsOpen()) {
-    LOG(ERROR) << "Client connection failed: " << client->StrError();
-    return;
-  }
-
-  clients_.emplace_back(device_pool_, client);
-}
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/server.h b/host/commands/virtual_usb_manager/usbip/server.h
deleted file mode 100644
index 5c574f7..0000000
--- a/host/commands/virtual_usb_manager/usbip/server.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <list>
-#include <string>
-
-#include "common/libs/fs/shared_fd.h"
-#include "host/commands/virtual_usb_manager/usbip/client.h"
-#include "host/commands/virtual_usb_manager/usbip/device_pool.h"
-
-namespace vadb {
-namespace usbip {
-
-class Server final {
- public:
-  Server(const std::string& name, const DevicePool& device_pool);
-  ~Server() = default;
-
-  // Initialize this instance of Server.
-  // Returns true, if initialization was successful.
-  bool Init();
-
-  // BeforeSelect is Called right before Select() to populate interesting
-  // SharedFDs.
-  void BeforeSelect(cvd::SharedFDSet* fd_read) const;
-
-  // AfterSelect is Called right after Select() to detect and respond to changes
-  // on affected SharedFDs.
-  void AfterSelect(const cvd::SharedFDSet& fd_read);
-
- private:
-  // Create USBIP server socket.
-  // Returns true, if socket was successfully created.
-  bool CreateServerSocket();
-
-  // Handle new client connection.
-  // New clients will be appended to clients_ list.
-  void HandleIncomingConnection();
-
-  std::string name_;
-  cvd::SharedFD server_;
-  std::list<Client> clients_;
-
-  const DevicePool& device_pool_;
-
-  Server(const Server&) = delete;
-  Server& operator=(const Server&) = delete;
-};
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/vhci_instrument.cpp b/host/commands/virtual_usb_manager/usbip/vhci_instrument.cpp
deleted file mode 100644
index 9df09ad..0000000
--- a/host/commands/virtual_usb_manager/usbip/vhci_instrument.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <errno.h>
-#include <string.h>
-
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <sys/socket.h>
-
-#include <glog/logging.h>
-#include <fstream>
-#include <limits>
-#include <sstream>
-#include "common/libs/fs/shared_select.h"
-
-#include "common/libs/fs/shared_fd.h"
-#include "host/commands/virtual_usb_manager/usbip/vhci_instrument.h"
-
-namespace vadb {
-namespace usbip {
-namespace {
-// Device ID is specified as a concatenated pair of BUS and DEVICE id.
-// Since we only export one device and our server doesn't care much about
-// its number, we use the default value of BUS=1 and DEVICE=1.
-// This can be set to something else and should still work, as long as
-// numbers are valid in USB sense.
-constexpr uint32_t kDefaultDeviceID = (1 << 16) | 1;
-
-// Request Highspeed configuration. Superspeed isn't supported by vhci.
-// Supported configurations are:
-//  4 -> wireless
-//  3 -> highspeed
-//  2 -> full speed
-//  1 -> low speed
-//  Please refer to the Kernel source tree in the following locations:
-//     include/uapi/linux/usb/ch9.h
-//     drivers/usb/usbip/vhci_sysfs.c
-constexpr uint32_t kDefaultDeviceSpeed = 3;
-
-// Subsystem and device type where VHCI driver is located.
-const char* const kVHCIPlatformPaths[] = {
-    "/sys/devices/platform/vhci_hcd",
-    "/sys/devices/platform/vhci_hcd.1",
-};
-
-// Control messages.
-// Attach tells thread to attach remote device.
-// Detach tells thread to detach remote device.
-using ControlMsgType = uint8_t;
-constexpr ControlMsgType kControlAttach = 'A';
-constexpr ControlMsgType kControlDetach = 'D';
-constexpr ControlMsgType kControlExit = 'E';
-
-// Used with EPOLL as epoll_data to determine event type.
-enum EpollEventType {
-  kControlEvent,
-  kVHCIEvent,
-};
-
-}  // anonymous namespace
-
-VHCIInstrument::VHCIInstrument(int port, const std::string& name)
-    : name_(name), port_{port} {}
-
-VHCIInstrument::~VHCIInstrument() {
-  control_write_end_->Write(&kControlExit, sizeof(kControlExit));
-  attach_thread_.join();
-}
-
-bool VHCIInstrument::Init() {
-  cvd::SharedFD::Pipe(&control_read_end_, &control_write_end_);
-
-  struct stat buf;
-  for (const auto* path : kVHCIPlatformPaths) {
-    if (stat(path, &buf) == 0) {
-      syspath_ = path;
-      break;
-    }
-  }
-
-  if (syspath_.empty()) {
-    LOG(ERROR) << "VHCI not available. Is the driver loaded?";
-    LOG(ERROR) << "Try: sudo modprobe vhci_hcd";
-    LOG(ERROR) << "The driver is part of linux-image-extra-`uname -r` package";
-    return false;
-  }
-
-  if (!VerifyPortIsFree()) {
-    LOG(ERROR) << "Trying to use VHCI port " << port_ << " but it is already in"
-               << " use.";
-    return false;
-  }
-
-  LOG(INFO) << "Using VHCI port " << port_;
-  attach_thread_ = std::thread([this] { AttachThread(); });
-  return true;
-}
-
-bool VHCIInstrument::VerifyPortIsFree() const {
-  std::ifstream status_file(syspath_ + "/status");
-
-  if (!status_file.good()) {
-    LOG(ERROR) << "Could not open usb-ip status file.";
-    return false;
-  }
-
-  // Skip past the header line.
-  status_file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
-
-  while (true) {
-    // Port status values deducted from /sys/devices/platform/vhci_hcd/status
-    // kVHCIPortFree indicates the port is not currently in use.
-    constexpr static int kVHCIStatusPortFree = 4;
-
-    int port{};
-    int status{};
-    status_file >> port >> status;
-    if (!status_file.good()) {
-      break;
-    }
-
-    status_file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
-    if (port_ == port) {
-      return status == kVHCIStatusPortFree;
-    }
-  }
-  LOG(ERROR) << "Couldn't find status for VHCI port " << port_;
-  return false;
-}
-
-void VHCIInstrument::TriggerAttach() {
-  control_write_end_->Write(&kControlAttach, sizeof(kControlAttach));
-}
-
-void VHCIInstrument::TriggerDetach() {
-  control_write_end_->Write(&kControlDetach, sizeof(kControlDetach));
-}
-
-void VHCIInstrument::AttachThread() {
-  cvd::SharedFD epoll = cvd::SharedFD::Epoll();
-  // Trigger attach upon start.
-  bool want_attach = true;
-  // Operation is pending on read.
-  bool is_pending = false;
-
-  epoll_event control_event;
-  control_event.events = EPOLLIN;
-  control_event.data.u64 = kControlEvent;
-  epoll_event vhci_event;
-  vhci_event.events = EPOLLRDHUP | EPOLLONESHOT;
-  vhci_event.data.u64 = kVHCIEvent;
-
-  epoll->EpollCtl(EPOLL_CTL_ADD, control_read_end_, &control_event);
-  while (true) {
-    if (vhci_socket_->IsOpen()) {
-      epoll->EpollCtl(EPOLL_CTL_ADD, vhci_socket_, &vhci_event);
-    }
-
-    epoll_event found_event{};
-    ControlMsgType request_type;
-
-    if (epoll->EpollWait(&found_event, 1, 1000)) {
-      switch (found_event.data.u64) {
-        case kControlEvent:
-          control_read_end_->Read(&request_type, sizeof(request_type));
-          is_pending = true;
-          want_attach = request_type == kControlAttach;
-          LOG(INFO) << (want_attach ? "Attach" : "Detach") << " triggered.";
-          break;
-        case kVHCIEvent:
-          vhci_socket_ = cvd::SharedFD();
-          // Only re-establish VHCI if it was already established before.
-          is_pending = want_attach;
-          // Do not immediately fall into attach cycle. It will likely complete
-          // before VHCI finishes deregistering this callback.
-          continue;
-      }
-    }
-
-    // Make an attempt to re-attach. If successful, clear pending attach flag.
-    if (is_pending) {
-      if (want_attach && Attach()) {
-        is_pending = false;
-      } else if (!want_attach && Detach()) {
-        is_pending = false;
-      } else {
-        LOG(INFO) << (want_attach ? "Attach" : "Detach") << " unsuccessful. "
-                  << "Will re-try.";
-        sleep(1);
-      }
-    }
-  }
-}
-
-bool VHCIInstrument::Detach() {
-  std::stringstream result;
-  result << port_;
-  std::ofstream detach(syspath_ + "/detach");
-
-  if (!detach.is_open()) {
-    LOG(WARNING) << "Could not open VHCI detach file.";
-    return false;
-  }
-  detach << result.str();
-  return detach.rdstate() == std::ios_base::goodbit;
-}
-
-bool VHCIInstrument::Attach() {
-  if (!vhci_socket_->IsOpen()) {
-    vhci_socket_ =
-        cvd::SharedFD::SocketLocalClient(name_.c_str(), true, SOCK_STREAM);
-    if (!vhci_socket_->IsOpen()) return false;
-  }
-
-  int sys_fd = vhci_socket_->UNMANAGED_Dup();
-  bool success = false;
-
-  {
-    std::stringstream result;
-    result << port_ << ' ' << sys_fd << ' ' << kDefaultDeviceID << ' '
-           << kDefaultDeviceSpeed;
-    std::string path = syspath_ + "/attach";
-    std::ofstream attach(path);
-
-    if (!attach.is_open()) {
-      LOG(WARNING) << "Could not open VHCI attach file " << path << " ("
-                   << strerror(errno) << ")";
-      close(sys_fd);
-      return false;
-    }
-    attach << result.str();
-
-    // It is unclear whether duplicate FD should remain open or not. There are
-    // cases supporting both assumptions, likely related to kernel version.
-    // Kernel 4.10 is having problems communicating with USB/IP server if the
-    // socket is closed after it's passed to kernel. It is a clear indication
-    // that the kernel requires the socket to be kept open.
-    success = attach.rdstate() == std::ios_base::goodbit;
-    // Make sure everything was written and flushed. This happens when we close
-    // the ofstream attach.
-  }
-
-  close(sys_fd);
-  return success;
-}
-
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/usbip/vhci_instrument.h b/host/commands/virtual_usb_manager/usbip/vhci_instrument.h
deleted file mode 100644
index aa2f5d4..0000000
--- a/host/commands/virtual_usb_manager/usbip/vhci_instrument.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <memory>
-#include <string>
-#include <thread>
-
-#include "common/libs/fs/shared_fd.h"
-
-namespace vadb {
-namespace usbip {
-// VHCIInstrument class configures VHCI-HCD on local kernel.
-class VHCIInstrument {
- public:
-  VHCIInstrument(int port, const std::string& name);
-  virtual ~VHCIInstrument();
-
-  // Init opens vhci-hcd driver and allocates port to which remote USB device
-  // will be attached.
-  // Returns false, if vhci-hcd driver could not be opened, or if no free port
-  // was found.
-  bool Init();
-
-  // TriggerAttach tells underlying thread to make attempt to re-attach USB
-  // device.
-  void TriggerAttach();
-
-  // TriggerDetach tells underlying thread to disconnect remote USB device.
-  void TriggerDetach();
-
- private:
-  // Attach makes an attempt to configure VHCI to enable virtual USB device.
-  // Returns true, if configuration attempt was successful.
-  bool Attach();
-
-  // Detach disconnects virtual USB device.
-  // Returns true, if attempt was successful.
-  bool Detach();
-
-  // AttachThread is a background thread that responds to configuration
-  // requests.
-  void AttachThread();
-  bool VerifyPortIsFree() const;
-
- private:
-  std::string name_;
-  std::thread attach_thread_;
-  std::string syspath_;
-  cvd::SharedFD control_write_end_;
-  cvd::SharedFD control_read_end_;
-  cvd::SharedFD vhci_socket_;
-  int port_{};
-
-  VHCIInstrument(const VHCIInstrument& other) = delete;
-  VHCIInstrument& operator=(const VHCIInstrument& other) = delete;
-};
-}  // namespace usbip
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd.h b/host/commands/virtual_usb_manager/vadb/usb_cmd.h
deleted file mode 100644
index 7039fbe..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "common/libs/fs/shared_fd.h"
-#include "common/libs/usbforward/protocol.h"
-
-namespace vadb {
-// USBCommand is an abstraction of a proxied USB command.
-// Instances of this object all share the following life cycle:
-// 1) A specific instance (COMMAND) is being created.
-// 2) Instance owner (OWNER) sends RequestHeader.
-// 3) OWNER calls COMMAND.OnRequest() to send any relevant, additional
-//    information.
-// 4) OWNER queues COMMAND until response arrives.
-//
-// At this point instance owner can process next command in queue. Then,
-// eventually:
-//
-// 5) OWNER receives matching ResponseHeader.
-// 6) OWNER calls COMMAND.OnResponse(), supplying FD that carries additional
-//    data.
-// 7) OWNER dequeues and deletes COMMAND.
-class USBCommand {
- public:
-  USBCommand() = default;
-  virtual ~USBCommand() = default;
-
-  // Command returns a specific usbforward command ID associated with this
-  // request.
-  virtual usb_forward::Command Command() = 0;
-
-  // OnRequest is called whenever additional data relevant to this command
-  // (other than RequestHeader) should be sent.
-  // Returns false, if communication with remote host failed (and should be
-  // terminated).
-  virtual bool OnRequest(const cvd::SharedFD& data) = 0;
-
-  // OnResponse is called whenever additional data relevant to this command
-  // (other than ResponseHeader) should be received.
-  // Returns false, if communication with remote host failed (and should be
-  // terminated).
-  virtual bool OnResponse(bool is_success, const cvd::SharedFD& data) = 0;
-
- private:
-  USBCommand(const USBCommand& other) = delete;
-  USBCommand& operator=(const USBCommand& other) = delete;
-};
-
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_attach.cpp b/host/commands/virtual_usb_manager/vadb/usb_cmd_attach.cpp
deleted file mode 100644
index 8418236..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_attach.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <glog/logging.h>
-
-#include "common/libs/usbforward/protocol.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_attach.h"
-
-namespace vadb {
-bool USBCmdAttach::OnRequest(const cvd::SharedFD& fd) {
-  if (fd->Write(&req_, sizeof(req_)) != sizeof(req_)) {
-    LOG(ERROR) << "Short write: " << fd->StrError();
-    return false;
-  }
-  return true;
-}
-
-bool USBCmdAttach::OnResponse(bool is_success, const cvd::SharedFD& /*data*/) {
-  if (!is_success) return false;
-  LOG(INFO) << "Attach successful.";
-  return true;
-}
-
-USBCmdAttach::USBCmdAttach(uint8_t bus_id, uint8_t dev_id) {
-  req_.bus_id = bus_id;
-  req_.dev_id = dev_id;
-}
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_attach.h b/host/commands/virtual_usb_manager/vadb/usb_cmd_attach.h
deleted file mode 100644
index 368deca..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_attach.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd.h"
-
-namespace vadb {
-// Request remote device attach (~open).
-class USBCmdAttach : public USBCommand {
- public:
-  USBCmdAttach(uint8_t bus_id, uint8_t dev_id);
-  ~USBCmdAttach() override = default;
-
-  // Return usbforward command this instance is executing.
-  usb_forward::Command Command() override { return usb_forward::CmdAttach; }
-
-  // Send request body to the server.
-  // Return false, if communication failed.
-  bool OnRequest(const cvd::SharedFD& data) override;
-
-  // Receive response data from the server.
-  // Return false, if communication failed.
-  bool OnResponse(bool is_success, const cvd::SharedFD& data) override;
-
- private:
-  usb_forward::AttachRequest req_;
-
-  USBCmdAttach(const USBCmdAttach& other) = delete;
-  USBCmdAttach& operator=(const USBCmdAttach& other) = delete;
-};
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.cpp b/host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.cpp
deleted file mode 100644
index 16fec69..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <glog/logging.h>
-
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.h"
-
-namespace vadb {
-USBCmdControlTransfer::USBCmdControlTransfer(
-    uint8_t bus_id, uint8_t dev_id, uint8_t type, uint8_t request,
-    uint16_t value, uint16_t index, uint32_t timeout, std::vector<uint8_t> data,
-    usbip::Device::AsyncTransferReadyCB callback)
-    : data_(std::move(data)), callback_(std::move(callback)) {
-  req_.bus_id = bus_id;
-  req_.dev_id = dev_id;
-  req_.type = type;
-  req_.cmd = request;
-  req_.value = value;
-  req_.index = index;
-  req_.length = data_.size();
-  req_.timeout = timeout;
-}
-
-bool USBCmdControlTransfer::OnRequest(const cvd::SharedFD& fd) {
-  if (fd->Write(&req_, sizeof(req_)) != sizeof(req_)) {
-    LOG(ERROR) << "Short write: " << fd->StrError();
-    return false;
-  }
-
-  if ((req_.type & 0x80) == 0) {
-    if (data_.size() > 0) {
-      if (static_cast<size_t>(fd->Write(data_.data(), data_.size())) !=
-          data_.size()) {
-        LOG(ERROR) << "Short write: " << fd->StrError();
-        return false;
-      }
-    }
-  }
-
-  return true;
-}
-
-bool USBCmdControlTransfer::OnResponse(bool is_success,
-                                       const cvd::SharedFD& fd) {
-  if (!is_success) {
-    callback_(false, std::move(data_));
-    return true;
-  }
-
-  if (req_.type & 0x80) {
-    int32_t len;
-    if (fd->Read(&len, sizeof(len)) != sizeof(len)) {
-      LOG(ERROR) << "Short read: " << fd->StrError();
-      callback_(false, std::move(data_));
-      return false;
-    }
-
-    if (len > 0) {
-      data_.resize(len);
-      if (fd->Read(data_.data(), len) != len) {
-        LOG(ERROR) << "Short read: " << fd->StrError();
-        callback_(false, std::move(data_));
-        return false;
-      }
-    }
-  }
-
-  callback_(true, std::move(data_));
-  return true;
-}
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.h b/host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.h
deleted file mode 100644
index 08aa159..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <memory>
-
-#include <stdint.h>
-
-#include "common/libs/usbforward/protocol.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd.h"
-#include "host/commands/virtual_usb_manager/usbip/device.h"
-
-namespace vadb {
-// Execute control transfer.
-class USBCmdControlTransfer : public USBCommand {
- public:
-  USBCmdControlTransfer(uint8_t bus_id, uint8_t dev_id, uint8_t type,
-                        uint8_t request, uint16_t value, uint16_t index,
-                        uint32_t timeout, std::vector<uint8_t> data,
-                        usbip::Device::AsyncTransferReadyCB callback);
-
-  ~USBCmdControlTransfer() override = default;
-
-  // Return usbforward command this instance is executing.
-  usb_forward::Command Command() override {
-    return usb_forward::CmdControlTransfer;
-  }
-
-  // Send request body to the server.
-  // Return false, if communication failed.
-  bool OnRequest(const cvd::SharedFD& data) override;
-
-  // Receive response data from the server.
-  // Return false, if communication failed.
-  bool OnResponse(bool is_success, const cvd::SharedFD& data) override;
-
- private:
-  usb_forward::ControlTransfer req_;
-  std::vector<uint8_t> data_;
-  usbip::Device::AsyncTransferReadyCB callback_;
-
-  USBCmdControlTransfer(const USBCmdControlTransfer& other) = delete;
-  USBCmdControlTransfer& operator=(const USBCmdControlTransfer& other) = delete;
-};
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.cpp b/host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.cpp
deleted file mode 100644
index 8de468f..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <glog/logging.h>
-
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.h"
-
-namespace vadb {
-USBCmdDataTransfer::USBCmdDataTransfer(
-    uint8_t bus_id, uint8_t dev_id, uint8_t endpoint, bool is_host_to_device,
-    uint32_t deadline, std::vector<uint8_t> data,
-    usbip::Device::AsyncTransferReadyCB callback)
-    : data_(std::move(data)), callback_(std::move(callback)) {
-  req_.bus_id = bus_id;
-  req_.dev_id = dev_id;
-  req_.endpoint_id = endpoint;
-  req_.is_host_to_device = is_host_to_device;
-  req_.length = data_.size();
-  req_.timeout = deadline;
-}
-
-bool USBCmdDataTransfer::OnRequest(const cvd::SharedFD& fd) {
-  if (fd->Write(&req_, sizeof(req_)) != sizeof(req_)) {
-    LOG(ERROR) << "Short write: " << fd->StrError();
-    return false;
-  }
-
-  if (req_.is_host_to_device && data_.size() > 0) {
-    if (static_cast<size_t>(fd->Write(data_.data(), data_.size())) !=
-        data_.size()) {
-      LOG(ERROR) << "Short write: " << fd->StrError();
-      return false;
-    }
-  }
-
-  return true;
-}
-
-bool USBCmdDataTransfer::OnResponse(bool is_success, const cvd::SharedFD& fd) {
-  if (!is_success) {
-    callback_(false, std::move(data_));
-    return true;
-  }
-
-  if (!req_.is_host_to_device) {
-    int32_t len;
-    if (fd->Read(&len, sizeof(len)) != sizeof(len)) {
-      LOG(ERROR) << "Short read: " << fd->StrError();
-      callback_(false, std::move(data_));
-      return false;
-    }
-
-    if (len > 0) {
-      data_.resize(len);
-      int32_t got = 0;
-      // Virtio sends data in 32k packets. We may have to do a few reads.
-      while (got < len) {
-        auto packetsize = fd->Read(&data_[got], len - got);
-        got += packetsize;
-
-        if (fd->GetErrno() != 0) {
-          // This could, technically, also be a disconnect.
-          LOG(ERROR) << "Read failed: " << fd->StrError();
-          return false;
-        } else if (packetsize == 0) {
-          LOG(ERROR) << "Short read; remote end disconnected.";
-          return false;
-        }
-      }
-    }
-  }
-
-  callback_(true, std::move(data_));
-  return true;
-}
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.h b/host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.h
deleted file mode 100644
index 3c4b64f..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <memory>
-#include <stdint.h>
-
-#include "common/libs/usbforward/protocol.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd.h"
-#include "host/commands/virtual_usb_manager/usbip/device.h"
-
-namespace vadb {
-// Execute control transfer.
-class USBCmdDataTransfer : public USBCommand {
- public:
-  USBCmdDataTransfer(uint8_t bus_id, uint8_t dev_id, uint8_t endpoint,
-                     bool is_host_to_device, uint32_t timeout,
-                     std::vector<uint8_t> data,
-                     usbip::Device::AsyncTransferReadyCB callback);
-
-  ~USBCmdDataTransfer() override = default;
-
-  // Return usbforward command this instance is executing.
-  usb_forward::Command Command() override {
-    return usb_forward::CmdDataTransfer;
-  }
-
-  // Send request body to the server.
-  // Return false, if communication failed.
-  bool OnRequest(const cvd::SharedFD& data) override;
-
-  // Receive response data from the server.
-  // Return false, if communication failed.
-  bool OnResponse(bool is_success, const cvd::SharedFD& data) override;
-
- private:
-  usb_forward::DataTransfer req_;
-  std::vector<uint8_t> data_;
-  usbip::Device::AsyncTransferReadyCB callback_;
-
-  USBCmdDataTransfer(const USBCmdDataTransfer& other) = delete;
-  USBCmdDataTransfer& operator=(const USBCmdDataTransfer& other) = delete;
-};
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.cpp b/host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.cpp
deleted file mode 100644
index b74efdd..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <glog/logging.h>
-
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.h"
-
-namespace vadb {
-bool USBCmdDeviceList::OnRequest(const cvd::SharedFD& /*data*/) {
-  LOG(INFO) << "Requesting device list from Cuttlefish...";
-  // No action required.
-  return true;
-}
-
-bool USBCmdDeviceList::OnResponse(bool is_success, const cvd::SharedFD& fd) {
-  // This should never happen. If this command fails, something is very wrong.
-  if (!is_success) return false;
-
-  int32_t count;
-  if (fd->Read(&count, sizeof(count)) != sizeof(count)) {
-    LOG(ERROR) << "Short read: " << fd->StrError();
-    return false;
-  }
-
-  LOG(INFO) << "Device list completed with " << count << " devices.";
-
-  while (count-- > 0) {
-    usb_forward::DeviceInfo dev;
-    std::vector<usb_forward::InterfaceInfo> ifaces;
-
-    if (fd->Read(&dev, sizeof(dev)) != sizeof(dev)) {
-      LOG(ERROR) << "Short read: " << fd->StrError();
-      return false;
-    }
-
-    ifaces.resize(dev.num_interfaces);
-    if (static_cast<size_t>(
-            fd->Read(ifaces.data(),
-                     ifaces.size() * sizeof(usb_forward::InterfaceInfo))) !=
-        ifaces.size() * sizeof(usb_forward::InterfaceInfo)) {
-      LOG(ERROR) << "Short read: " << fd->StrError();
-      return false;
-    }
-
-    LOG(INFO) << "Found remote device 0x" << std::hex << dev.vendor_id << ":"
-              << dev.product_id;
-
-    on_device_discovered_(dev, ifaces);
-  }
-
-  return true;
-}
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.h b/host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.h
deleted file mode 100644
index 4d9ebbc..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <functional>
-#include <vector>
-#include "common/libs/usbforward/protocol.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd.h"
-
-namespace vadb {
-// Request device list from remote host.
-class USBCmdDeviceList : public USBCommand {
- public:
-  // DeviceDiscoveredCB is a callback function invoked for every new discovered
-  // device.
-  using DeviceDiscoveredCB =
-      std::function<void(const usb_forward::DeviceInfo&,
-                         const std::vector<usb_forward::InterfaceInfo>&)>;
-
-  USBCmdDeviceList(DeviceDiscoveredCB cb)
-      : on_device_discovered_(std::move(cb)) {}
-
-  ~USBCmdDeviceList() override = default;
-
-  // Return usbforward command this instance is executing.
-  usb_forward::Command Command() override { return usb_forward::CmdDeviceList; }
-
-  // Send request body to the server.
-  // Return false, if communication failed.
-  bool OnRequest(const cvd::SharedFD& data) override;
-
-  // Receive response data from the server.
-  // Return false, if communication failed.
-  bool OnResponse(bool is_success, const cvd::SharedFD& data) override;
-
- private:
-  DeviceDiscoveredCB on_device_discovered_;
-  USBCmdDeviceList(const USBCmdDeviceList& other) = delete;
-  USBCmdDeviceList& operator=(const USBCmdDeviceList& other) = delete;
-};
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.cpp b/host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.cpp
deleted file mode 100644
index cc80caa..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <glog/logging.h>
-
-#include "common/libs/usbforward/protocol.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.h"
-
-namespace vadb {
-bool USBCmdHeartbeat::OnRequest(const cvd::SharedFD& /*fd*/) { return true; }
-
-bool USBCmdHeartbeat::OnResponse(bool is_success,
-                                 const cvd::SharedFD& /*data*/) {
-  callback_(is_success);
-  return true;
-}
-
-USBCmdHeartbeat::USBCmdHeartbeat(USBCmdHeartbeat::HeartbeatResultCB callback)
-    : callback_(callback) {}
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.h b/host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.h
deleted file mode 100644
index 552165b..0000000
--- a/host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd.h"
-
-namespace vadb {
-// Request remote device attach (~open).
-class USBCmdHeartbeat : public USBCommand {
- public:
-  // Heartbeat result callback receives a boolean argument indicating whether
-  // remote device is ready to be attached.
-  using HeartbeatResultCB = std::function<void(bool)>;
-
-  USBCmdHeartbeat(HeartbeatResultCB callback);
-  ~USBCmdHeartbeat() override = default;
-
-  // Return usbforward command this instance is executing.
-  usb_forward::Command Command() override { return usb_forward::CmdHeartbeat; }
-
-  // Send request body to the server.
-  // Return false, if communication failed.
-  bool OnRequest(const cvd::SharedFD& data) override;
-
-  // Receive response data from the server.
-  // Return false, if communication failed.
-  bool OnResponse(bool is_success, const cvd::SharedFD& data) override;
-
- private:
-  HeartbeatResultCB callback_;
-
-  USBCmdHeartbeat(const USBCmdHeartbeat& other) = delete;
-  USBCmdHeartbeat& operator=(const USBCmdHeartbeat& other) = delete;
-};
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/virtual_adb_client.cpp b/host/commands/virtual_usb_manager/vadb/virtual_adb_client.cpp
deleted file mode 100644
index 34ee5b4..0000000
--- a/host/commands/virtual_usb_manager/vadb/virtual_adb_client.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <algorithm>
-#include <memory>
-#include <gflags/gflags.h>
-
-#include "common/libs/fs/shared_select.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_attach.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_control_transfer.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_data_transfer.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_device_list.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd_heartbeat.h"
-#include "host/commands/virtual_usb_manager/vadb/virtual_adb_client.h"
-
-DEFINE_bool(debug_adb_client, false, "Turn on verbose logging in the virtual_adb_client.cpp");
-
-#define VLOG(X) if (FLAGS_debug_adb_client) LOG(VERBOSE)
-
-namespace vadb {
-namespace {
-constexpr int kHeartbeatTimeoutSeconds = 3;
-}  // namespace
-
-VirtualADBClient::VirtualADBClient(usbip::DevicePool* pool, cvd::SharedFD fd,
-                                   int vhci_port,
-                                   const std::string& usbip_socket_name)
-    : pool_{pool}, fd_{fd}, vhci_{vhci_port, usbip_socket_name} {
-  CHECK(vhci_.Init());
-  timer_ = cvd::SharedFD::TimerFD(CLOCK_MONOTONIC, 0);
-  SendHeartbeat();
-}
-
-void VirtualADBClient::RegisterDevice(
-    const usb_forward::DeviceInfo& dev,
-    const std::vector<usb_forward::InterfaceInfo>& ifaces) {
-  auto d = std::unique_ptr<usbip::Device>(new usbip::Device);
-  d->vendor_id = dev.vendor_id;
-  d->product_id = dev.product_id;
-  d->dev_version = dev.dev_version;
-  d->dev_class = dev.dev_class;
-  d->dev_subclass = dev.dev_subclass;
-  d->dev_protocol = dev.dev_protocol;
-  d->speed = dev.speed;
-  d->configurations_count = dev.num_configurations;
-  d->configuration_number = dev.cur_configuration;
-
-  for (const auto& iface : ifaces) {
-    d->interfaces.push_back(usbip::Device::Interface{
-        iface.if_class, iface.if_subclass, iface.if_protocol});
-  }
-
-  uint8_t bus_id = dev.bus_id;
-  uint8_t dev_id = dev.dev_id;
-
-  d->handle_attach = [this, bus_id, dev_id]() -> bool {
-    return HandleAttach(bus_id, dev_id);
-  };
-
-  d->handle_control_transfer =
-      [this, bus_id, dev_id](
-          const usbip::CmdRequest& r, uint32_t deadline,
-          std::vector<uint8_t> data,
-          usbip::Device::AsyncTransferReadyCB callback) -> bool {
-    return HandleDeviceControlRequest(bus_id, dev_id, r, deadline,
-                                      std::move(data), std::move(callback));
-  };
-
-  d->handle_data_transfer =
-      [this, bus_id, dev_id](
-          uint8_t endpoint, bool is_host_to_device, uint32_t deadline,
-          std::vector<uint8_t> data,
-          usbip::Device::AsyncTransferReadyCB callback) -> bool {
-    return HandleDeviceDataRequest(bus_id, dev_id, endpoint, is_host_to_device,
-                                   deadline, std::move(data),
-                                   std::move(callback));
-  };
-
-  pool_->AddDevice(usbip::DevicePool::BusDevNumber{bus_id, dev_id},
-                   std::move(d));
-
-  // Attach this device.
-  HandleAttach(bus_id, dev_id);
-}
-
-bool VirtualADBClient::PopulateRemoteDevices() {
-  return ExecuteCommand(std::unique_ptr<USBCommand>(new USBCmdDeviceList(
-      [this](const usb_forward::DeviceInfo& info,
-             const std::vector<usb_forward::InterfaceInfo>& ifaces) {
-        RegisterDevice(info, ifaces);
-      })));
-}
-
-bool VirtualADBClient::HandleDeviceControlRequest(
-    uint8_t bus_id, uint8_t dev_id, const usbip::CmdRequest& r,
-    uint32_t timeout, std::vector<uint8_t> data,
-    usbip::Device::AsyncTransferReadyCB callback) {
-  return ExecuteCommand(std::unique_ptr<USBCommand>(new USBCmdControlTransfer(
-      bus_id, dev_id, r.type, r.cmd, r.value, r.index, timeout, std::move(data),
-      std::move(callback))));
-}
-
-bool VirtualADBClient::HandleDeviceDataRequest(
-    uint8_t bus_id, uint8_t dev_id, uint8_t endpoint, bool is_host_to_device,
-    uint32_t deadline, std::vector<uint8_t> data,
-    usbip::Device::AsyncTransferReadyCB callback) {
-  return ExecuteCommand(std::unique_ptr<USBCommand>(
-      new USBCmdDataTransfer(bus_id, dev_id, endpoint, is_host_to_device,
-                             deadline, std::move(data), std::move(callback))));
-}
-
-bool VirtualADBClient::HandleAttach(uint8_t bus_id, uint8_t dev_id) {
-  return ExecuteCommand(
-      std::unique_ptr<USBCommand>(new USBCmdAttach(bus_id, dev_id)));
-}
-
-bool VirtualADBClient::SendHeartbeat() {
-  VLOG(1) << "Sending heartbeat...";
-  struct itimerspec spec {};
-  spec.it_value.tv_sec = kHeartbeatTimeoutSeconds;
-  timer_->TimerSet(0, &spec, nullptr);
-
-  heartbeat_tag_ = tag_;
-
-  return ExecuteCommand(std::unique_ptr<USBCommand>(
-      new USBCmdHeartbeat([this](bool success) { HandleHeartbeat(success); })));
-}
-
-void VirtualADBClient::HandleHeartbeat(bool is_ready) {
-  VLOG(1) << "Remote server status: " << is_ready;
-  if (is_ready && !is_remote_server_ready_) {
-    LOG(INFO) << "Remote server is now ready.";
-    PopulateRemoteDevices();
-    vhci_.TriggerAttach();
-  } else if (is_remote_server_ready_ && !is_ready) {
-    vhci_.TriggerDetach();
-    LOG(WARNING) << "Remote server connection lost.";
-    // It makes perfect sense to cancel all outstanding USB requests, as device
-    // is not going to answer any of these anyway.
-    for (const auto& pair : commands_) {
-      pair.second->OnResponse(false, fd_);
-    }
-    commands_.clear();
-  }
-  is_remote_server_ready_ = is_ready;
-}
-
-bool VirtualADBClient::HandleHeartbeatTimeout() {
-  uint64_t timer_result;
-  timer_->Read(&timer_result, sizeof(timer_result));
-
-  auto iter = commands_.find(heartbeat_tag_);
-  if (iter != commands_.end()) {
-    // Make sure to erase the value from list of commands prior to running
-    // callback. Particularly important for heartbeat, which cancels all
-    // outstanding USB commands (including self, if found), if device goes
-    // away (eg. reboots).
-    auto command = std::move(iter->second);
-    commands_.erase(iter);
-    command->OnResponse(false, fd_);
-  }
-
-  return SendHeartbeat();
-}
-
-bool VirtualADBClient::ExecuteCommand(std::unique_ptr<USBCommand> cmd) {
-  uint32_t this_tag = tag_;
-  tag_++;
-  usb_forward::RequestHeader hdr{cmd->Command(), this_tag};
-  if (fd_->Write(&hdr, sizeof(hdr)) != sizeof(hdr)) {
-    LOG(ERROR) << "Could not contact USB Forwarder: " << fd_->StrError();
-    return false;
-  }
-
-  if (!cmd->OnRequest(fd_)) return false;
-
-  commands_[this_tag] = std::move(cmd);
-  return true;
-}
-
-// BeforeSelect is Called right before Select() to populate interesting
-// SharedFDs.
-void VirtualADBClient::BeforeSelect(cvd::SharedFDSet* fd_read) const {
-  fd_read->Set(fd_);
-  fd_read->Set(timer_);
-}
-
-// AfterSelect is Called right after Select() to detect and respond to changes
-// on affected SharedFDs.
-// Return value indicates whether this client is still valid.
-bool VirtualADBClient::AfterSelect(const cvd::SharedFDSet& fd_read) {
-  if (fd_read.IsSet(timer_)) {
-    HandleHeartbeatTimeout();
-  }
-  if (fd_read.IsSet(fd_)) {
-    usb_forward::ResponseHeader rhdr;
-    if (fd_->Read(&rhdr, sizeof(rhdr)) != sizeof(rhdr)) {
-      LOG(ERROR) << "Could not read from USB Forwarder: " << fd_->StrError();
-      // TODO(ender): it is very likely the connection has been dropped by QEmu.
-      // Should we cancel all pending commands now?
-      return false;
-    }
-
-    auto iter = commands_.find(rhdr.tag);
-    if (iter == commands_.end()) {
-      // This is likely a late heartbeat response, but could very well be any of
-      // the remaining commands.
-      LOG(INFO) << "Received response for discarded tag " << rhdr.tag;
-    } else {
-      // Make sure to erase the value from list of commands prior to running
-      // callback. Particularly important for heartbeat, which cancels all
-      // outstanding USB commands (including self, if found), if device goes
-      // away (eg. reboots).
-      auto command = std::move(iter->second);
-      commands_.erase(iter);
-      command->OnResponse(rhdr.status == usb_forward::StatusSuccess, fd_);
-    }
-  }
-
-  return true;
-}
-
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/virtual_adb_client.h b/host/commands/virtual_usb_manager/vadb/virtual_adb_client.h
deleted file mode 100644
index 9c503ab..0000000
--- a/host/commands/virtual_usb_manager/vadb/virtual_adb_client.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <string>
-
-#include "common/libs/fs/shared_fd.h"
-#include "common/libs/fs/shared_select.h"
-#include "common/libs/usbforward/protocol.h"
-#include "host/commands/virtual_usb_manager/vadb/usb_cmd.h"
-#include "host/commands/virtual_usb_manager/usbip/device.h"
-#include "host/commands/virtual_usb_manager/usbip/device_pool.h"
-#include "host/commands/virtual_usb_manager/usbip/messages.h"
-#include "host/commands/virtual_usb_manager/usbip/vhci_instrument.h"
-
-namespace vadb {
-// VirtualADBClient is a companion class for USBForwarder, running on
-// Cuttlefish. VirtualADBClient collects list of available USB devices from
-// Cuttlefish and makes them available to USB/IP.
-//
-// Purpose of this class is to connect to USBForwarder and make access to
-// remote USB devices possible with help of USB/IP protocol.
-class VirtualADBClient {
- public:
-  VirtualADBClient(usbip::DevicePool* pool, cvd::SharedFD fd, int vhci_port,
-                   const std::string& usbip_socket_name);
-
-  virtual ~VirtualADBClient() = default;
-
-  // Query remote server; populate available USB devices.
-  bool PopulateRemoteDevices();
-
-  // BeforeSelect is Called right before Select() to populate interesting
-  // SharedFDs.
-  void BeforeSelect(cvd::SharedFDSet* fd_read) const;
-
-  // AfterSelect is Called right after Select() to detect and respond to changes
-  // on affected SharedFDs.
-  // Return value indicates whether this client is still valid.
-  bool AfterSelect(const cvd::SharedFDSet& fd_read);
-
- private:
-  // Register new device in a device pool.
-  void RegisterDevice(const usb_forward::DeviceInfo& dev,
-                      const std::vector<usb_forward::InterfaceInfo>& ifaces);
-
-  // Request attach remote USB device.
-  bool HandleAttach(uint8_t bus_id, uint8_t dev_id);
-
-  // Execute control request on remote device.
-  bool HandleDeviceControlRequest(uint8_t bus_id, uint8_t dev_id,
-                                  const usbip::CmdRequest& r, uint32_t deadline,
-                                  std::vector<uint8_t> data,
-                                  usbip::Device::AsyncTransferReadyCB callback);
-
-  // Execute data request on remote device.
-  bool HandleDeviceDataRequest(uint8_t bus_id, uint8_t dev_id, uint8_t endpoint,
-                               bool is_host_to_device, uint32_t deadline,
-                               std::vector<uint8_t> data,
-                               usbip::Device::AsyncTransferReadyCB callback);
-
-  // Send new heartbeat request and arm the heartbeat timer.
-  bool SendHeartbeat();
-
-  // Heartbeat handler receives response to heartbeat request.
-  // Supplied argument indicates, whether remote server is ready to export USB
-  // gadget.
-  void HandleHeartbeat(bool is_ready);
-
-  // Heartbeat timeout detects situation where heartbeat did not receive
-  // matching response. This could be a direct result of device reset.
-  bool HandleHeartbeatTimeout();
-
-  // ExecuteCommand creates command header and executes supplied USBCommand.
-  // If execution was successful, command will be stored internally until
-  // response arrives.
-  bool ExecuteCommand(std::unique_ptr<USBCommand> cmd);
-
-  usbip::DevicePool* pool_;
-  cvd::SharedFD fd_;
-  cvd::SharedFD timer_;
-  usbip::VHCIInstrument vhci_;
-  bool is_remote_server_ready_ = false;
-
-  uint32_t tag_ = 0;
-  // Assign an 'invalid' tag as previously sent heartbeat command. This will
-  // prevent heartbeat timeout handler from finding a command if none was sent.
-  uint32_t heartbeat_tag_ = ~0;
-  std::map<uint32_t, std::unique_ptr<USBCommand>> commands_;
-
-  VirtualADBClient(const VirtualADBClient& other) = delete;
-  VirtualADBClient& operator=(const VirtualADBClient& other) = delete;
-};
-
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/virtual_adb_server.cpp b/host/commands/virtual_usb_manager/vadb/virtual_adb_server.cpp
deleted file mode 100644
index 43dae75..0000000
--- a/host/commands/virtual_usb_manager/vadb/virtual_adb_server.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "host/commands/virtual_usb_manager/vadb/virtual_adb_server.h"
-
-namespace vadb {
-
-void VirtualADBServer::BeforeSelect(cvd::SharedFDSet* fd_read) const {
-  fd_read->Set(server_);
-  for (const auto& client : clients_) {
-    client.BeforeSelect(fd_read);
-  }
-}
-
-void VirtualADBServer::AfterSelect(const cvd::SharedFDSet& fd_read) {
-  if (fd_read.IsSet(server_)) HandleIncomingConnection();
-
-  for (auto iter = clients_.begin(); iter != clients_.end();) {
-    if (!iter->AfterSelect(fd_read)) {
-      // If client conversation failed, hang up.
-      iter = clients_.erase(iter);
-      continue;
-    }
-    ++iter;
-  }
-}
-
-// Accept new QEmu connection. Add it to client pool.
-// Typically we will have no more than one QEmu connection, but the nature
-// of server requires proper handling nonetheless.
-void VirtualADBServer::HandleIncomingConnection() {
-  cvd::SharedFD client = cvd::SharedFD::Accept(*server_, nullptr, nullptr);
-  if (!client->IsOpen()) {
-    LOG(ERROR) << "Client connection failed: " << client->StrError();
-    return;
-  }
-
-  clients_.emplace_back(&pool_, client, vhci_port_, usbip_name_);
-}
-
-}  // namespace vadb
diff --git a/host/commands/virtual_usb_manager/vadb/virtual_adb_server.h b/host/commands/virtual_usb_manager/vadb/virtual_adb_server.h
deleted file mode 100644
index d4aaf79..0000000
--- a/host/commands/virtual_usb_manager/vadb/virtual_adb_server.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <list>
-#include <string>
-
-#include "common/libs/fs/shared_fd.h"
-#include "host/commands/virtual_usb_manager/usbip/device_pool.h"
-#include "host/commands/virtual_usb_manager/vadb/virtual_adb_client.h"
-
-namespace vadb {
-// VirtualADBServer manages incoming VirtualUSB/ADB connections from QEmu.
-class VirtualADBServer {
- public:
-  VirtualADBServer(cvd::SharedFD usb_v1_socket, int vhci_port,
-                   const std::string& usbip_socket_name)
-      : vhci_port_{vhci_port},
-        usbip_name_(usbip_socket_name),
-        server_(usb_v1_socket) {}
-
-  ~VirtualADBServer() = default;
-
-  // Pool of USB devices available to export.
-  const usbip::DevicePool& Pool() const { return pool_; };
-
-  // BeforeSelect is Called right before Select() to populate interesting
-  // SharedFDs.
-  void BeforeSelect(cvd::SharedFDSet* fd_read) const;
-
-  // AfterSelect is Called right after Select() to detect and respond to changes
-  // on affected SharedFDs.
-  void AfterSelect(const cvd::SharedFDSet& fd_read);
-
- private:
-  void HandleIncomingConnection();
-
-  usbip::DevicePool pool_;
-  int vhci_port_{};
-  std::string usbip_name_;
-  cvd::SharedFD server_;
-  std::list<VirtualADBClient> clients_;
-
-  VirtualADBServer(const VirtualADBServer&) = delete;
-  VirtualADBServer& operator=(const VirtualADBServer&) = delete;
-};
-
-}  // namespace vadb
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index ae89a21..1820ee4 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -93,9 +93,6 @@
 const char* kVendorRamdiskImagePath = "vendor_ramdisk_image_path";
 
 const char* kVirtualDiskPaths = "virtual_disk_paths";
-const char* kUsbV1SocketName = "usb_v1_socket_name";
-const char* kVhciPort = "vhci_port";
-const char* kUsbIpSocketName = "usb_ip_socket_name";
 const char* kDeprecatedBootCompleted = "deprecated_boot_completed";
 
 const char* kMobileBridgeName = "mobile_bridge_name";
@@ -123,7 +120,6 @@
 const char* kRestartSubprocesses = "restart_subprocesses";
 const char* kRunAdbConnector = "run_adb_connector";
 const char* kAdbConnectorBinary = "adb_connector_binary";
-const char* kVirtualUsbManagerBinary = "virtual_usb_manager_binary";
 const char* kSocketVsockProxyBinary = "socket_vsock_proxy_binary";
 
 const char* kRunAsDaemon = "run_as_daemon";
@@ -331,29 +327,6 @@
   (*dictionary_)[kVirtualDiskPaths] = virtual_disks_json_obj;
 }
 
-std::string CuttlefishConfig::usb_v1_socket_name() const {
-  return (*dictionary_)[kUsbV1SocketName].asString();
-}
-void CuttlefishConfig::set_usb_v1_socket_name(
-    const std::string& usb_v1_socket_name) {
-  (*dictionary_)[kUsbV1SocketName] = usb_v1_socket_name;
-}
-
-int CuttlefishConfig::vhci_port() const {
-  return (*dictionary_)[kVhciPort].asInt();
-}
-void CuttlefishConfig::set_vhci_port(int vhci_port) {
-  (*dictionary_)[kVhciPort] = vhci_port;
-}
-
-std::string CuttlefishConfig::usb_ip_socket_name() const {
-  return (*dictionary_)[kUsbIpSocketName].asString();
-}
-void CuttlefishConfig::set_usb_ip_socket_name(
-    const std::string& usb_ip_socket_name) {
-  (*dictionary_)[kUsbIpSocketName] = usb_ip_socket_name;
-}
-
 std::string CuttlefishConfig::kernel_log_pipe_name() const {
   return cvd::AbsolutePath(PerInstanceInternalPath("kernel-log-pipe"));
 }
@@ -438,8 +411,6 @@
     return AdbMode::VsockHalfTunnel;
   } else if (mode == "native_vsock") {
     return AdbMode::NativeVsock;
-  } else if (mode == "usb") {
-    return AdbMode::Usb;
   } else {
     return AdbMode::Unknown;
   }
@@ -484,8 +455,6 @@
   bool nativeVsock = adb_mode().count(AdbMode::NativeVsock) > 0;
   if (vsockTunnel || vsockHalfProxy || nativeVsock) {
     return adb_ip_and_port();
-  } else if (adb_mode().count(AdbMode::Usb) > 0) {
-    return serial_number();
   }
   LOG(ERROR) << "no adb_mode found, returning bad device name";
   return "NO_ADB_MODE_SET_NO_VALID_DEVICE_NAME";
@@ -591,15 +560,6 @@
   (*dictionary_)[kAdbConnectorBinary] = adb_connector_binary;
 }
 
-std::string CuttlefishConfig::virtual_usb_manager_binary() const {
-  return (*dictionary_)[kVirtualUsbManagerBinary].asString();
-}
-
-void CuttlefishConfig::set_virtual_usb_manager_binary(
-    const std::string& virtual_usb_manager_binary) {
-  (*dictionary_)[kVirtualUsbManagerBinary] = virtual_usb_manager_binary;
-}
-
 std::string CuttlefishConfig::socket_vsock_proxy_binary() const {
   return (*dictionary_)[kSocketVsockProxyBinary].asString();
 }
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index aea9055..656f84f 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -42,7 +42,6 @@
   VsockTunnel,
   VsockHalfTunnel,
   NativeVsock,
-  Usb,
   Unknown,
 };
 
@@ -64,11 +63,6 @@
 
   std::string instance_name() const;
 
-  void disable_usb_adb() {
-    // This seems to be the way usb is being disbled in the launcher
-    set_usb_v1_socket_name("");
-  }
-
   std::string instance_dir() const;
   void set_instance_dir(const std::string& instance_dir);
 
@@ -150,17 +144,6 @@
   std::vector<std::string> virtual_disk_paths() const;
   void set_virtual_disk_paths(const std::vector<std::string>& disk_paths);
 
-  // The name of the socket that will be used to forward access to USB gadget.
-  // This is for V1 of the USB bus.
-  std::string usb_v1_socket_name() const;
-  void set_usb_v1_socket_name(const std::string& usb_v1_socket_name);
-
-  int vhci_port() const;
-  void set_vhci_port(int vhci_port);
-
-  std::string usb_ip_socket_name() const;
-  void set_usb_ip_socket_name(const std::string& usb_ip_socket_name);
-
   std::string kernel_log_pipe_name() const;
 
   std::string console_pipe_name() const;
@@ -248,9 +231,6 @@
   void set_adb_connector_binary(const std::string& adb_connector_binary);
   std::string adb_connector_binary() const;
 
-  void set_virtual_usb_manager_binary(const std::string& binary);
-  std::string virtual_usb_manager_binary() const;
-
   void set_socket_vsock_proxy_binary(const std::string& binary);
   std::string socket_vsock_proxy_binary() const;
 
diff --git a/host/libs/vm_manager/cf_qemu.sh b/host/libs/vm_manager/cf_qemu.sh
index 969332d..5d88b3f 100755
--- a/host/libs/vm_manager/cf_qemu.sh
+++ b/host/libs/vm_manager/cf_qemu.sh
@@ -159,13 +159,6 @@
   args+=(-initrd "${ramdisk_image_path}")
 fi
 
-if [[ -n "${usb_v1_socket_name}" ]]; then
-  args+=(
-      -chardev "socket,id=charchannel1,path=${usb_v1_socket_name:-${default_internal_dir}/usb-v1}"
-      -device "virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=cf-gadget-usb-v1"
-  )
-fi
-
 if [[ ${vsock_guest_cid:-0} -gt 2 ]]; then
   args+=(-device "vhost-vsock-pci,guest-cid=${vsock_guest_cid}")
 fi
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index 45e3003..c5345c1 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -146,7 +146,6 @@
                config_->kernel_log_pipe_name());
   LogAndSetEnv("console_path", config_->console_path());
   LogAndSetEnv("logcat_path", config_->logcat_path());
-  LogAndSetEnv("usb_v1_socket_name", config_->usb_v1_socket_name());
   LogAndSetEnv("vsock_guest_cid", std::to_string(config_->vsock_guest_cid()));
   LogAndSetEnv("logcat_mode", config_->logcat_mode());
   LogAndSetEnv("use_bootloader", config_->use_bootloader() ? "true" : "false");
diff --git a/host_package.mk b/host_package.mk
index 1eac968..66246f2 100644
--- a/host_package.mk
+++ b/host_package.mk
@@ -27,7 +27,6 @@
     vnc_server \
     cf_qemu.sh \
     cf_bpttool \
-    virtual_usb_manager \
     kernel_log_monitor \
     extract-vmlinux \
     crosvm \