blob: 112c13a4ebee02cdc2cd370b026d9940994f85f6 [file] [log] [blame]
Spencer Low142ec752015-05-06 16:13:42 -07001/*
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
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080017#ifndef _ADB_CLIENT_H_
18#define _ADB_CLIENT_H_
19
20#include "adb.h"
Josh Gaof3f6a1d2016-01-31 19:12:26 -080021#include "transport.h"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080022
Elliott Hughes078f0fc2015-04-29 08:35:59 -070023#include <string>
24
Spencer Low142ec752015-05-06 16:13:42 -070025// Connect to adb, connect to the named service, and return a valid fd for
26// interacting with that service upon success or a negative number on failure.
Elliott Hughes6452a892015-04-29 12:28:13 -070027int adb_connect(const std::string& service, std::string* error);
28int _adb_connect(const std::string& service, std::string* error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080029
Elliott Hughes424af022015-05-29 17:55:19 -070030// Connect to adb, connect to the named service, returns true if the connection
31// succeeded AND the service returned OKAY. Outputs any returned error otherwise.
32bool adb_command(const std::string& service);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080033
Elliott Hughes6452a892015-04-29 12:28:13 -070034// Connects to the named adb service and fills 'result' with the response.
35// Returns true on success; returns false and fills 'error' on failure.
36bool adb_query(const std::string& service, std::string* result, std::string* error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080037
Elliott Hughes3bd73c12015-05-05 13:10:43 -070038// Set the preferred transport to connect to.
39void adb_set_transport(TransportType type, const char* serial);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080040
Spencer Low142ec752015-05-06 16:13:42 -070041// Set TCP specifics of the transport to use.
Stefan Hilzingerd0eacb82010-04-19 12:21:12 +010042void adb_set_tcp_specifics(int server_port);
43
Spencer Low142ec752015-05-06 16:13:42 -070044// Set TCP Hostname of the transport to use.
Matt Gumbeld7b33082012-11-14 10:16:17 -080045void adb_set_tcp_name(const char* hostname);
46
Spencer Low142ec752015-05-06 16:13:42 -070047// Send commands to the current emulator instance. Will fail if there is not
48// exactly one emulator connected (or if you use -s <serial> with a <serial>
49// that does not designate an emulator).
50int adb_send_emulator_command(int argc, const char** argv, const char* serial);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080051
Spencer Low142ec752015-05-06 16:13:42 -070052// Reads a standard adb status response (OKAY|FAIL) and returns true in the
53// event of OKAY, false in the event of FAIL or protocol error.
Elliott Hughes078f0fc2015-04-29 08:35:59 -070054bool adb_status(int fd, std::string* error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080055
Josh Gaof3f6a1d2016-01-31 19:12:26 -080056// Create a host command corresponding to selected transport type/serial.
57std::string format_host_command(const char* command, TransportType type, const char* serial);
58
59// Get the feature set of the current preferred transport.
60bool adb_get_feature_set(FeatureSet* feature_set, std::string* error);
61
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080062#endif