| 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 { |
| Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 28 | namespace platform_android { |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 29 | |
| 30 | class AdbClient |
| 31 | { |
| 32 | public: |
| 33 | using DeviceIDList = std::list<std::string>; |
| 34 | |
| Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 35 | static Error |
| Chaoren Lin | 3ea689b | 2015-05-01 16:49:28 +0000 | [diff] [blame] | 36 | CreateByDeviceID(const std::string &device_id, AdbClient &adb); |
| Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 37 | |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 38 | AdbClient () = default; |
| 39 | explicit AdbClient (const std::string &device_id); |
| 40 | |
| Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 41 | const std::string& |
| 42 | GetDeviceID() const; |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 43 | |
| 44 | Error |
| 45 | GetDevices (DeviceIDList &device_list); |
| 46 | |
| 47 | Error |
| 48 | SetPortForwarding (const uint16_t port); |
| 49 | |
| 50 | Error |
| 51 | DeletePortForwarding (const uint16_t port); |
| 52 | |
| Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 53 | Error |
| 54 | PullFile (const char *remote_file, const char *local_file); |
| 55 | |
| Robert Flack | 62efb1f | 2015-05-27 02:18:50 +0000 | [diff] [blame^] | 56 | Error |
| 57 | PushFile (const lldb_private::FileSpec& source, const lldb_private::FileSpec& destination); |
| 58 | |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 59 | private: |
| 60 | Error |
| 61 | Connect (); |
| 62 | |
| Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 63 | void |
| Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 64 | SetDeviceID (const std::string &device_id); |
| Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 65 | |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 66 | Error |
| Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 67 | SendMessage (const std::string &packet, const bool reconnect = true); |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 68 | |
| 69 | Error |
| 70 | SendDeviceMessage (const std::string &packet); |
| 71 | |
| 72 | Error |
| Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 73 | SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data); |
| 74 | |
| 75 | Error |
| 76 | ReadSyncHeader (std::string &response_id, uint32_t &data_len); |
| 77 | |
| 78 | Error |
| 79 | ReadMessage (std::vector<char> &message); |
| 80 | |
| 81 | Error |
| 82 | GetResponseError (const char *response_id); |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 83 | |
| 84 | Error |
| 85 | ReadResponseStatus (); |
| 86 | |
| Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 87 | Error |
| 88 | SwitchDeviceTransport (); |
| 89 | |
| 90 | Error |
| 91 | Sync (); |
| 92 | |
| 93 | Error |
| 94 | PullFileChunk (std::vector<char> &buffer, bool &eof); |
| 95 | |
| 96 | Error |
| 97 | ReadAllBytes (void *buffer, size_t size); |
| 98 | |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 99 | std::string m_device_id; |
| 100 | ConnectionFileDescriptor m_conn; |
| 101 | }; |
| 102 | |
| Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 103 | } // namespace platform_android |
| Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 104 | } // namespace lldb_private |
| 105 | |
| 106 | #endif // liblldb_AdbClient_h_ |