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 #include <glog/logging.h> 17 18 #include "common/libs/usbforward/protocol.h" 19 #include "host/libs/vadb/usb_cmd_attach.h" 20 21 namespace vadb { 22 bool USBCmdAttach::OnRequest(const cvd::SharedFD& fd) { 23 if (fd->Write(&req_, sizeof(req_)) != sizeof(req_)) { 24 LOG(ERROR) << "Short write: " << fd->StrError(); 25 return false; 26 } 27 return true; 28 } 29 30 bool USBCmdAttach::OnResponse(bool is_success, const cvd::SharedFD& /*data*/) { 31 if (!is_success) return false; 32 LOG(INFO) << "Attach successful."; 33 return true; 34 } 35 36 USBCmdAttach::USBCmdAttach(uint8_t bus_id, uint8_t dev_id) { 37 req_.bus_id = bus_id; 38 req_.dev_id = dev_id; 39 } 40 } // namespace vadb 41