blob: 5b6fdac33ba4254b962122a4e27742327086758b [file] [log] [blame]
JP Abgrall408fa572011-03-16 15:57:42 -07001/*
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 Alberte9fca142015-02-18 18:03:26 -080020#include <sys/types.h>
21
Elliott Hughes7be29c82015-04-16 22:54:44 -070022#include <string>
Dan Albert76649012015-02-24 15:51:19 -080023
Elliott Hughes7be29c82015-04-16 22:54:44 -070024#include "adb.h"
Dan Albert630b9af2014-11-24 23:34:35 -080025
Dan Albert76649012015-02-24 15:51:19 -080026/*
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 */
32atransport* acquire_one_transport(int state, transport_type ttype,
Elliott Hughes7be29c82015-04-16 22:54:44 -070033 const char* serial, std::string* error_out);
Dan Albert76649012015-02-24 15:51:19 -080034void add_transport_disconnect(atransport* t, adisconnect* dis);
35void remove_transport_disconnect(atransport* t, adisconnect* dis);
36void kick_transport(atransport* t);
37void run_transport_disconnects(atransport* t);
38void update_transports(void);
39
40/* transports are ref-counted
41** get_device_transport does an acquire on your behalf before returning
42*/
43void init_transport_registration(void);
Elliott Hughese67f1f82015-04-30 17:32:03 -070044std::string list_transports(bool long_listing);
Dan Albert76649012015-02-24 15:51:19 -080045atransport* find_transport(const char* serial);
46
47void 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 */
51int 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 */
54void unregister_usb_transport(usb_handle* usb);
55
56/* these should only be used for the "adb disconnect" command */
57void unregister_transport(atransport* t);
58void unregister_all_tcp_transports();
59
60int check_header(apacket* p);
61int check_data(apacket* p);
62
63/* for MacOS X cleanup */
64void close_usb_devices();
65
66void send_packet(apacket* p, atransport* t);
67
68asocket* create_device_tracker(void);
69
JP Abgrall408fa572011-03-16 15:57:42 -070070#endif /* __TRANSPORT_H */