1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 #include "host/commands/virtual_usb_manager/vadb/usb_cmd.h" 19 20 namespace vadb { 21 // Request remote device attach (~open). 22 class USBCmdAttach : public USBCommand { 23 public: 24 USBCmdAttach(uint8_t bus_id, uint8_t dev_id); 25 ~USBCmdAttach() override = default; 26 27 // Return usbforward command this instance is executing. Command()28 usb_forward::Command Command() override { return usb_forward::CmdAttach; } 29 30 // Send request body to the server. 31 // Return false, if communication failed. 32 bool OnRequest(const cvd::SharedFD& data) override; 33 34 // Receive response data from the server. 35 // Return false, if communication failed. 36 bool OnResponse(bool is_success, const cvd::SharedFD& data) override; 37 38 private: 39 usb_forward::AttachRequest req_; 40 41 USBCmdAttach(const USBCmdAttach& other) = delete; 42 USBCmdAttach& operator=(const USBCmdAttach& other) = delete; 43 }; 44 } // namespace vadb 45