1 /* 2 * Copyright (C) 2011 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 17 #ifndef __TRANSPORT_H 18 #define __TRANSPORT_H 19 20 #include <sys/types.h> 21 22 #include <string> 23 24 #include "adb.h" 25 26 /* 27 * Obtain a transport from the available transports. 28 * If state is != CS_ANY, only transports in that state are considered. 29 * If serial is non-NULL then only the device with that serial will be chosen. 30 * If no suitable transport is found, error is set. 31 */ 32 atransport* acquire_one_transport(int state, transport_type ttype, 33 const char* serial, std::string* error_out); 34 void add_transport_disconnect(atransport* t, adisconnect* dis); 35 void remove_transport_disconnect(atransport* t, adisconnect* dis); 36 void kick_transport(atransport* t); 37 void run_transport_disconnects(atransport* t); 38 void update_transports(void); 39 40 /* transports are ref-counted 41 ** get_device_transport does an acquire on your behalf before returning 42 */ 43 void init_transport_registration(void); 44 std::string list_transports(bool long_listing); 45 atransport* find_transport(const char* serial); 46 47 void register_usb_transport(usb_handle* h, const char* serial, 48 const char* devpath, unsigned writeable); 49 50 /* cause new transports to be init'd and added to the list */ 51 int register_socket_transport(int s, const char* serial, int port, int local); 52 53 /* this should only be used for transports with connection_state == CS_NOPERM */ 54 void unregister_usb_transport(usb_handle* usb); 55 56 /* these should only be used for the "adb disconnect" command */ 57 void unregister_transport(atransport* t); 58 void unregister_all_tcp_transports(); 59 60 int check_header(apacket* p); 61 int check_data(apacket* p); 62 63 /* for MacOS X cleanup */ 64 void close_usb_devices(); 65 66 void send_packet(apacket* p, atransport* t); 67 68 asocket* create_device_tracker(void); 69 70 #endif /* __TRANSPORT_H */ 71