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 | |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 56 | private: |
| 57 | Error |
| 58 | Connect (); |
| 59 | |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 60 | void |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 61 | SetDeviceID (const std::string &device_id); |
Oleksiy Vyalov | 6f00106 | 2015-03-25 17:58:13 +0000 | [diff] [blame] | 62 | |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 63 | Error |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 64 | SendMessage (const std::string &packet, const bool reconnect = true); |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 65 | |
| 66 | Error |
| 67 | SendDeviceMessage (const std::string &packet); |
| 68 | |
| 69 | Error |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 70 | SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data); |
| 71 | |
| 72 | Error |
| 73 | ReadSyncHeader (std::string &response_id, uint32_t &data_len); |
| 74 | |
| 75 | Error |
| 76 | ReadMessage (std::vector<char> &message); |
| 77 | |
| 78 | Error |
| 79 | GetResponseError (const char *response_id); |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 80 | |
| 81 | Error |
| 82 | ReadResponseStatus (); |
| 83 | |
Oleksiy Vyalov | 09e9079d | 2015-05-18 23:44:06 +0000 | [diff] [blame] | 84 | Error |
| 85 | SwitchDeviceTransport (); |
| 86 | |
| 87 | Error |
| 88 | Sync (); |
| 89 | |
| 90 | Error |
| 91 | PullFileChunk (std::vector<char> &buffer, bool &eof); |
| 92 | |
| 93 | Error |
| 94 | ReadAllBytes (void *buffer, size_t size); |
| 95 | |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 96 | std::string m_device_id; |
| 97 | ConnectionFileDescriptor m_conn; |
| 98 | }; |
| 99 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 100 | } // namespace platform_android |
Oleksiy Vyalov | 05a55de | 2015-03-23 21:03:02 +0000 | [diff] [blame] | 101 | } // namespace lldb_private |
| 102 | |
| 103 | #endif // liblldb_AdbClient_h_ |