Spencer Low | 7dc759f | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 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 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 17 | #ifndef _ADB_CLIENT_H_ |
| 18 | #define _ADB_CLIENT_H_ |
| 19 | |
| 20 | #include "adb.h" |
| 21 | |
Elliott Hughes | 04a98c2 | 2015-04-29 08:35:59 -0700 | [diff] [blame] | 22 | #include <string> |
| 23 | |
Spencer Low | 7dc759f | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 24 | // Connect to adb, connect to the named service, and return a valid fd for |
| 25 | // interacting with that service upon success or a negative number on failure. |
Elliott Hughes | da94581 | 2015-04-29 12:28:13 -0700 | [diff] [blame] | 26 | int adb_connect(const std::string& service, std::string* error); |
| 27 | int _adb_connect(const std::string& service, std::string* error); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 28 | |
Elliott Hughes | d98ca8a | 2015-05-29 17:55:19 -0700 | [diff] [blame] | 29 | // Connect to adb, connect to the named service, returns true if the connection |
| 30 | // succeeded AND the service returned OKAY. Outputs any returned error otherwise. |
| 31 | bool adb_command(const std::string& service); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 32 | |
Elliott Hughes | da94581 | 2015-04-29 12:28:13 -0700 | [diff] [blame] | 33 | // Connects to the named adb service and fills 'result' with the response. |
| 34 | // Returns true on success; returns false and fills 'error' on failure. |
| 35 | bool adb_query(const std::string& service, std::string* result, std::string* error); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 36 | |
Elliott Hughes | 3aec2ba | 2015-05-05 13:10:43 -0700 | [diff] [blame] | 37 | // Set the preferred transport to connect to. |
| 38 | void adb_set_transport(TransportType type, const char* serial); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 39 | |
Spencer Low | 7dc759f | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 40 | // Set TCP specifics of the transport to use. |
Stefan Hilzinger | fb798d9 | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 41 | void adb_set_tcp_specifics(int server_port); |
| 42 | |
Spencer Low | 7dc759f | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 43 | // Set TCP Hostname of the transport to use. |
Matt Gumbel | 411775c | 2012-11-14 10:16:17 -0800 | [diff] [blame] | 44 | void adb_set_tcp_name(const char* hostname); |
| 45 | |
Spencer Low | 7dc759f | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 46 | // Send commands to the current emulator instance. Will fail if there is not |
| 47 | // exactly one emulator connected (or if you use -s <serial> with a <serial> |
| 48 | // that does not designate an emulator). |
| 49 | int adb_send_emulator_command(int argc, const char** argv, const char* serial); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 50 | |
Spencer Low | 7dc759f | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 51 | // Reads a standard adb status response (OKAY|FAIL) and returns true in the |
| 52 | // event of OKAY, false in the event of FAIL or protocol error. |
Elliott Hughes | 04a98c2 | 2015-04-29 08:35:59 -0700 | [diff] [blame] | 53 | bool adb_status(int fd, std::string* error); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 54 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 55 | #endif |