blob: f1c8d7dfdb95d79191a328b212461dcc49a9760a [file] [log] [blame]
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +00001//===-- 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 Vyalov09e9079d2015-05-18 23:44:06 +000019#include <vector>
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000020
21// Other libraries and framework includes
22// Project includes
23
24#include "lldb/Core/Error.h"
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000025#include "lldb/Host/ConnectionFileDescriptor.h"
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000026
27namespace lldb_private {
Oleksiy Vyalov0b5ebef2015-05-28 17:42:48 +000028
29class FileSpec;
30
Tamas Berghammerdb264a62015-03-31 09:52:22 +000031namespace platform_android {
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000032
33class AdbClient
34{
35public:
36 using DeviceIDList = std::list<std::string>;
37
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000038 static Error
Chaoren Lin3ea689b2015-05-01 16:49:28 +000039 CreateByDeviceID(const std::string &device_id, AdbClient &adb);
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000040
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000041 AdbClient () = default;
42 explicit AdbClient (const std::string &device_id);
43
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000044 const std::string&
45 GetDeviceID() const;
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000046
47 Error
48 GetDevices (DeviceIDList &device_list);
49
50 Error
51 SetPortForwarding (const uint16_t port);
52
53 Error
54 DeletePortForwarding (const uint16_t port);
55
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000056 Error
Oleksiy Vyalov0b5ebef2015-05-28 17:42:48 +000057 PullFile (const FileSpec &remote_file, const FileSpec &local_file);
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000058
Robert Flack62efb1f2015-05-27 02:18:50 +000059 Error
Oleksiy Vyalov0b5ebef2015-05-28 17:42:48 +000060 PushFile (const FileSpec &local_file, const FileSpec &remote_file);
Robert Flack62efb1f2015-05-27 02:18:50 +000061
Oleksiy Vyalov6002a312015-06-05 01:32:45 +000062 Error
63 Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime);
64
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000065private:
66 Error
67 Connect ();
68
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000069 void
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000070 SetDeviceID (const std::string &device_id);
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000071
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000072 Error
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000073 SendMessage (const std::string &packet, const bool reconnect = true);
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000074
75 Error
76 SendDeviceMessage (const std::string &packet);
77
78 Error
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000079 SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data);
80
81 Error
82 ReadSyncHeader (std::string &response_id, uint32_t &data_len);
83
84 Error
85 ReadMessage (std::vector<char> &message);
86
87 Error
88 GetResponseError (const char *response_id);
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000089
90 Error
91 ReadResponseStatus ();
92
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000093 Error
94 SwitchDeviceTransport ();
95
96 Error
97 Sync ();
98
99 Error
Oleksiy Vyalov0b5ebef2015-05-28 17:42:48 +0000100 StartSync ();
101
102 Error
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +0000103 PullFileChunk (std::vector<char> &buffer, bool &eof);
104
105 Error
106 ReadAllBytes (void *buffer, size_t size);
107
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +0000108 std::string m_device_id;
109 ConnectionFileDescriptor m_conn;
110};
111
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000112} // namespace platform_android
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +0000113} // namespace lldb_private
114
115#endif // liblldb_AdbClient_h_