JP Abgrall | 408fa57 | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 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 | |
Dan Albert | e9fca14 | 2015-02-18 18:03:26 -0800 | [diff] [blame] | 20 | #include <sys/types.h> |
| 21 | |
Elliott Hughes | 7be29c8 | 2015-04-16 22:54:44 -0700 | [diff] [blame] | 22 | #include <string> |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 23 | |
Elliott Hughes | 7be29c8 | 2015-04-16 22:54:44 -0700 | [diff] [blame] | 24 | #include "adb.h" |
Dan Albert | 630b9af | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 25 | |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 26 | /* |
| 27 | * Obtain a transport from the available transports. |
Dan Albert | dcd78a1 | 2015-05-18 16:43:57 -0700 | [diff] [blame^] | 28 | * If state is != kCsAny, only transports in that state are considered. |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 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 | */ |
Dan Albert | dcd78a1 | 2015-05-18 16:43:57 -0700 | [diff] [blame^] | 32 | atransport* acquire_one_transport(ConnectionState state, TransportType type, |
Elliott Hughes | 7be29c8 | 2015-04-16 22:54:44 -0700 | [diff] [blame] | 33 | const char* serial, std::string* error_out); |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 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); |
Elliott Hughes | e67f1f8 | 2015-04-30 17:32:03 -0700 | [diff] [blame] | 44 | std::string list_transports(bool long_listing); |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 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 | |
Dan Albert | dcd78a1 | 2015-05-18 16:43:57 -0700 | [diff] [blame^] | 53 | // This should only be used for transports with connection_state == kCsNoPerm. |
Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 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 | |
JP Abgrall | 408fa57 | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 70 | #endif /* __TRANSPORT_H */ |