• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 _ADB_CLIENT_H_
18 #define _ADB_CLIENT_H_
19 
20 #include "adb.h"
21 #include "sysdeps.h"
22 #include "transport.h"
23 
24 #include <string>
25 
26 // Connect to adb, connect to the named service, and return a valid fd for
27 // interacting with that service upon success or a negative number on failure.
28 int adb_connect(const std::string& service, std::string* _Nonnull error);
29 int _adb_connect(const std::string& service, std::string* _Nonnull error);
30 
31 // Connect to adb, connect to the named service, returns true if the connection
32 // succeeded AND the service returned OKAY. Outputs any returned error otherwise.
33 bool adb_command(const std::string& service);
34 
35 // Connects to the named adb service and fills 'result' with the response.
36 // Returns true on success; returns false and fills 'error' on failure.
37 bool adb_query(const std::string& service, std::string* _Nonnull result,
38                std::string* _Nonnull error);
39 
40 // Set the preferred transport to connect to.
41 void adb_set_transport(TransportType type, const char* _Nullable serial);
42 
43 // Get the preferred transport to connect to.
44 void adb_get_transport(TransportType* _Nullable type, const char* _Nullable* _Nullable serial);
45 
46 // Set TCP specifics of the transport to use.
47 void adb_set_tcp_specifics(int server_port);
48 
49 // Set TCP Hostname of the transport to use.
50 void adb_set_tcp_name(const char* _Nullable hostname);
51 
52 // Send commands to the current emulator instance. Will fail if there is not
53 // exactly one emulator connected (or if you use -s <serial> with a <serial>
54 // that does not designate an emulator).
55 int adb_send_emulator_command(int argc, const char* _Nonnull* _Nonnull argv,
56                               const char* _Nullable serial);
57 
58 // Reads a standard adb status response (OKAY|FAIL) and returns true in the
59 // event of OKAY, false in the event of FAIL or protocol error.
60 bool adb_status(int fd, std::string* _Nonnull error);
61 
62 // Create a host command corresponding to selected transport type/serial.
63 std::string format_host_command(const char* _Nonnull command, TransportType type,
64                                 const char* _Nullable serial);
65 
66 // Get the feature set of the current preferred transport.
67 bool adb_get_feature_set(FeatureSet* _Nonnull feature_set, std::string* _Nonnull error);
68 
69 #endif
70