| Spencer Low | 142ec75 | 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 | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 17 | #ifndef _ADB_CLIENT_H_ | 
|  | 18 | #define _ADB_CLIENT_H_ | 
|  | 19 |  | 
|  | 20 | #include "adb.h" | 
| Josh Gao | f3f6a1d | 2016-01-31 19:12:26 -0800 | [diff] [blame] | 21 | #include "transport.h" | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 22 |  | 
| Elliott Hughes | 078f0fc | 2015-04-29 08:35:59 -0700 | [diff] [blame] | 23 | #include <string> | 
|  | 24 |  | 
| Spencer Low | 142ec75 | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 25 | // 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. | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 27 | int adb_connect(const std::string& service, std::string* _Nonnull error); | 
|  | 28 | int _adb_connect(const std::string& service, std::string* _Nonnull error); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 29 |  | 
| Elliott Hughes | 424af02 | 2015-05-29 17:55:19 -0700 | [diff] [blame] | 30 | // 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. | 
|  | 32 | bool adb_command(const std::string& service); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 33 |  | 
| Elliott Hughes | 6452a89 | 2015-04-29 12:28:13 -0700 | [diff] [blame] | 34 | // Connects to the named adb service and fills 'result' with the response. | 
|  | 35 | // Returns true on success; returns false and fills 'error' on failure. | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 36 | bool adb_query(const std::string& service, std::string* _Nonnull result, | 
|  | 37 | std::string* _Nonnull error); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 38 |  | 
| Elliott Hughes | 3bd73c1 | 2015-05-05 13:10:43 -0700 | [diff] [blame] | 39 | // Set the preferred transport to connect to. | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 40 | void adb_set_transport(TransportType type, const char* _Nullable serial); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 41 |  | 
| Josh Gao | d262122 | 2016-03-04 15:16:18 -0800 | [diff] [blame] | 42 | // Get the preferred transport to connect to. | 
|  | 43 | void adb_get_transport(TransportType* _Nullable type, const char* _Nullable* _Nullable serial); | 
|  | 44 |  | 
| Spencer Low | 142ec75 | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 45 | // Set TCP specifics of the transport to use. | 
| Stefan Hilzinger | d0eacb8 | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 46 | void adb_set_tcp_specifics(int server_port); | 
|  | 47 |  | 
| Spencer Low | 142ec75 | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 48 | // Set TCP Hostname of the transport to use. | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 49 | void adb_set_tcp_name(const char* _Nullable hostname); | 
| Matt Gumbel | d7b3308 | 2012-11-14 10:16:17 -0800 | [diff] [blame] | 50 |  | 
| Spencer Low | 142ec75 | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 51 | // Send commands to the current emulator instance. Will fail if there is not | 
|  | 52 | // exactly one emulator connected (or if you use -s <serial> with a <serial> | 
|  | 53 | // that does not designate an emulator). | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 54 | int adb_send_emulator_command(int argc, const char* _Nonnull* _Nonnull argv, | 
|  | 55 | const char* _Nullable serial); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 56 |  | 
| Spencer Low | 142ec75 | 2015-05-06 16:13:42 -0700 | [diff] [blame] | 57 | // Reads a standard adb status response (OKAY|FAIL) and returns true in the | 
|  | 58 | // event of OKAY, false in the event of FAIL or protocol error. | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 59 | bool adb_status(int fd, std::string* _Nonnull error); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 60 |  | 
| Josh Gao | f3f6a1d | 2016-01-31 19:12:26 -0800 | [diff] [blame] | 61 | // Create a host command corresponding to selected transport type/serial. | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 62 | std::string format_host_command(const char* _Nonnull command, TransportType type, | 
|  | 63 | const char* _Nullable serial); | 
| Josh Gao | f3f6a1d | 2016-01-31 19:12:26 -0800 | [diff] [blame] | 64 |  | 
|  | 65 | // Get the feature set of the current preferred transport. | 
| Josh Gao | a166e71 | 2016-01-29 12:08:34 -0800 | [diff] [blame] | 66 | bool adb_get_feature_set(FeatureSet* _Nonnull feature_set, std::string* _Nonnull error); | 
| Josh Gao | f3f6a1d | 2016-01-31 19:12:26 -0800 | [diff] [blame] | 67 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 68 | #endif |