blob: d07c1e96bc1c886dd6e75e1fd5e64a0127fe0a43 [file] [log] [blame]
Spencer Low7dc759f2015-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 Project9ca14dc2009-03-03 19:32:55 -080017#ifndef _ADB_CLIENT_H_
18#define _ADB_CLIENT_H_
19
20#include "adb.h"
Felipe Leme042c3512016-07-19 17:07:22 -070021#include "sysdeps.h"
Josh Gao91d53b52016-01-31 19:12:26 -080022#include "transport.h"
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080023
Elliott Hughes04a98c22015-04-29 08:35:59 -070024#include <string>
25
Spencer Low7dc759f2015-05-06 16:13:42 -070026// 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.
Josh Gao23f6f2b2016-01-29 12:08:34 -080028int adb_connect(const std::string& service, std::string* _Nonnull error);
29int _adb_connect(const std::string& service, std::string* _Nonnull error);
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080030
Elliott Hughesd98ca8a2015-05-29 17:55:19 -070031// 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.
33bool adb_command(const std::string& service);
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080034
Elliott Hughesda945812015-04-29 12:28:13 -070035// Connects to the named adb service and fills 'result' with the response.
36// Returns true on success; returns false and fills 'error' on failure.
Josh Gao23f6f2b2016-01-29 12:08:34 -080037bool adb_query(const std::string& service, std::string* _Nonnull result,
38 std::string* _Nonnull error);
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080039
Elliott Hughes3aec2ba2015-05-05 13:10:43 -070040// Set the preferred transport to connect to.
Josh Gao23f6f2b2016-01-29 12:08:34 -080041void adb_set_transport(TransportType type, const char* _Nullable serial);
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080042
Josh Gaobb4f8602016-08-25 16:00:22 -070043// Set the socket specification for the adb server.
44// This function can only be called once, and the argument must live to the end of the process.
45void adb_set_socket_spec(const char* _Nonnull socket_spec);
Matt Gumbel411775c2012-11-14 10:16:17 -080046
Spencer Low7dc759f2015-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).
Josh Gao23f6f2b2016-01-29 12:08:34 -080050int adb_send_emulator_command(int argc, const char* _Nonnull* _Nonnull argv,
51 const char* _Nullable serial);
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080052
Spencer Low7dc759f2015-05-06 16:13:42 -070053// Reads a standard adb status response (OKAY|FAIL) and returns true in the
54// event of OKAY, false in the event of FAIL or protocol error.
Josh Gao23f6f2b2016-01-29 12:08:34 -080055bool adb_status(int fd, std::string* _Nonnull error);
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080056
Josh Gao91d53b52016-01-31 19:12:26 -080057// Create a host command corresponding to selected transport type/serial.
Josh Gao23f6f2b2016-01-29 12:08:34 -080058std::string format_host_command(const char* _Nonnull command, TransportType type,
59 const char* _Nullable serial);
Josh Gao91d53b52016-01-31 19:12:26 -080060
61// Get the feature set of the current preferred transport.
Josh Gao23f6f2b2016-01-29 12:08:34 -080062bool adb_get_feature_set(FeatureSet* _Nonnull feature_set, std::string* _Nonnull error);
Josh Gao91d53b52016-01-31 19:12:26 -080063
The Android Open Source Project9ca14dc2009-03-03 19:32:55 -080064#endif