Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 1 | //===-- AdbClient.h ---------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef liblldb_AdbClient_h_ |
| 11 | #define liblldb_AdbClient_h_ |
| 12 | |
| 13 | // C Includes |
| 14 | |
| 15 | // C++ Includes |
| 16 | |
| 17 | #include <list> |
| 18 | #include <string> |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 19 | #include <vector> |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 20 | |
| 21 | // Other libraries and framework includes |
| 22 | // Project includes |
| 23 | |
| 24 | #include "lldb/Core/Error.h" |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 25 | #include "lldb/Host/ConnectionFileDescriptor.h" |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 26 | |
| 27 | namespace lldb_private { |
Oleksiy Vyalov | 0b5ebef | 2015-05-28 17:42:48 +0000 | [diff] [blame] | 28 | |
| 29 | class FileSpec; |
| 30 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 31 | namespace platform_android { |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 32 | |
| 33 | class AdbClient |
| 34 | { |
| 35 | public: |
| 36 | using DeviceIDList = std::list<std::string>; |
| 37 | |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 38 | static Error |
Chaoren Lin | 3ea689b | 2015-05-01 16:49:28 +0000 | [diff] [blame] | 39 | CreateByDeviceID(const std::string &device_id, AdbClient &adb); |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 40 | |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 41 | AdbClient () = default; |
| 42 | explicit AdbClient (const std::string &device_id); |
| 43 | |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 44 | const std::string& |
| 45 | GetDeviceID() const; |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 46 | |
| 47 | Error |
| 48 | GetDevices (DeviceIDList &device_list); |
| 49 | |
| 50 | Error |
Oleksiy Vyalov | e7eabbb | 2015-09-01 19:02:14 +0000 | [diff] [blame] | 51 | SetPortForwarding (const uint16_t local_port, const uint16_t remote_port); |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 52 | |
| 53 | Error |
Oleksiy Vyalov | 9fe526c | 2015-10-21 19:34:26 +0000 | [diff] [blame] | 54 | SetPortForwarding (const uint16_t local_port, const char* remote_socket_name); |
| 55 | |
| 56 | Error |
Oleksiy Vyalov | e7eabbb | 2015-09-01 19:02:14 +0000 | [diff] [blame] | 57 | DeletePortForwarding (const uint16_t local_port); |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 58 | |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 59 | Error |
Oleksiy Vyalov | 0b5ebef | 2015-05-28 17:42:48 +0000 | [diff] [blame] | 60 | PullFile (const FileSpec &remote_file, const FileSpec &local_file); |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 61 | |
Robert Flack | 62efb1f | 2015-05-27 02:18:50 +0000 | [diff] [blame] | 62 | Error |
Oleksiy Vyalov | 0b5ebef | 2015-05-28 17:42:48 +0000 | [diff] [blame] | 63 | PushFile (const FileSpec &local_file, const FileSpec &remote_file); |
Robert Flack | 62efb1f | 2015-05-27 02:18:50 +0000 | [diff] [blame] | 64 | |
Oleksiy Vyalov | 6002a31 | 2015-06-05 01:32:45 +0000 | [diff] [blame] | 65 | Error |
| 66 | Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime); |
| 67 | |
Tamas Berghammer | 9d8dde8 | 2015-09-29 11:04:18 +0000 | [diff] [blame] | 68 | Error |
| 69 | Shell (const char* command, uint32_t timeout_ms, std::string* output); |
| 70 | |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 71 | private: |
| 72 | Error |
| 73 | Connect (); |
| 74 | |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 75 | void |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 76 | SetDeviceID (const std::string &device_id); |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 77 | |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 78 | Error |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 79 | SendMessage (const std::string &packet, const bool reconnect = true); |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 80 | |
| 81 | Error |
| 82 | SendDeviceMessage (const std::string &packet); |
| 83 | |
| 84 | Error |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 85 | SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data); |
| 86 | |
| 87 | Error |
| 88 | ReadSyncHeader (std::string &response_id, uint32_t &data_len); |
| 89 | |
| 90 | Error |
| 91 | ReadMessage (std::vector<char> &message); |
| 92 | |
| 93 | Error |
Tamas Berghammer | 9d8dde8 | 2015-09-29 11:04:18 +0000 | [diff] [blame] | 94 | ReadMessageStream (std::vector<char> &message, uint32_t timeout_ms); |
| 95 | |
| 96 | Error |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 97 | GetResponseError (const char *response_id); |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 98 | |
| 99 | Error |
| 100 | ReadResponseStatus (); |
| 101 | |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 102 | Error |
| 103 | SwitchDeviceTransport (); |
| 104 | |
| 105 | Error |
| 106 | Sync (); |
| 107 | |
| 108 | Error |
Oleksiy Vyalov | 0b5ebef | 2015-05-28 17:42:48 +0000 | [diff] [blame] | 109 | StartSync (); |
| 110 | |
| 111 | Error |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 112 | PullFileChunk (std::vector<char> &buffer, bool &eof); |
| 113 | |
| 114 | Error |
| 115 | ReadAllBytes (void *buffer, size_t size); |
| 116 | |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 117 | std::string m_device_id; |
| 118 | ConnectionFileDescriptor m_conn; |
| 119 | }; |
| 120 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 121 | } // namespace platform_android |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 122 | } // namespace lldb_private |
| 123 | |
| 124 | #endif // liblldb_AdbClient_h_ |