blob: de5c2db73f79107edb7dd4c0e2bc659569204896 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001#ifndef _ADB_CLIENT_H_
2#define _ADB_CLIENT_H_
3
4#include "adb.h"
5
Elliott Hughes078f0fc2015-04-29 08:35:59 -07006#include <string>
7
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08008/* connect to adb, connect to the named service, and return
9** a valid fd for interacting with that service upon success
10** or a negative number on failure
11*/
Elliott Hughes6452a892015-04-29 12:28:13 -070012int adb_connect(const std::string& service, std::string* error);
13int _adb_connect(const std::string& service, std::string* error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080014
15/* connect to adb, connect to the named service, return 0 if
16** the connection succeeded AND the service returned OKAY
17*/
Elliott Hughes6452a892015-04-29 12:28:13 -070018int adb_command(const std::string& service, std::string* error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080019
Elliott Hughes6452a892015-04-29 12:28:13 -070020// Connects to the named adb service and fills 'result' with the response.
21// Returns true on success; returns false and fills 'error' on failure.
22bool adb_query(const std::string& service, std::string* result, std::string* error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080023
Elliott Hughes3bd73c12015-05-05 13:10:43 -070024// Set the preferred transport to connect to.
25void adb_set_transport(TransportType type, const char* serial);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080026
Stefan Hilzingerd0eacb82010-04-19 12:21:12 +010027/* Set TCP specifics of the transport to use
28*/
29void adb_set_tcp_specifics(int server_port);
30
Matt Gumbeld7b33082012-11-14 10:16:17 -080031/* Set TCP Hostname of the transport to use
32*/
33void adb_set_tcp_name(const char* hostname);
34
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080035/* Return the console port of the currently connected emulator (if any)
36 * of -1 if there is no emulator, and -2 if there is more than one.
37 * assumes adb_set_transport() was alled previously...
38 */
39int adb_get_emulator_console_port(void);
40
41/* send commands to the current emulator instance. will fail if there
42 * is zero, or more than one emulator connected (or if you use -s <serial>
43 * with a <serial> that does not designate an emulator)
44 */
Dan Albertbac34742015-02-25 17:51:28 -080045int adb_send_emulator_command(int argc, const char** argv);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080046
Elliott Hughes078f0fc2015-04-29 08:35:59 -070047// Reads a standard adb status response (OKAY|FAIL) and
48// returns true in the event of OKAY, false in the event of FAIL
49// or protocol error.
50bool adb_status(int fd, std::string* error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080051
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080052#endif