blob: d307b6a298a9219dde2cb2a067e9557aa847164b [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 {
Tamas Berghammerdb264a62015-03-31 09:52:22 +000028namespace platform_android {
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000029
30class AdbClient
31{
32public:
33 using DeviceIDList = std::list<std::string>;
34
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000035 static Error
Chaoren Lin3ea689b2015-05-01 16:49:28 +000036 CreateByDeviceID(const std::string &device_id, AdbClient &adb);
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000037
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000038 AdbClient () = default;
39 explicit AdbClient (const std::string &device_id);
40
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000041 const std::string&
42 GetDeviceID() const;
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000043
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 Vyalov09e9079d2015-05-18 23:44:06 +000053 Error
54 PullFile (const char *remote_file, const char *local_file);
55
Robert Flack62efb1f2015-05-27 02:18:50 +000056 Error
57 PushFile (const lldb_private::FileSpec& source, const lldb_private::FileSpec& destination);
58
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000059private:
60 Error
61 Connect ();
62
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000063 void
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000064 SetDeviceID (const std::string &device_id);
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000065
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000066 Error
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000067 SendMessage (const std::string &packet, const bool reconnect = true);
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000068
69 Error
70 SendDeviceMessage (const std::string &packet);
71
72 Error
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000073 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 Vyalov05a55de2015-03-23 21:03:02 +000083
84 Error
85 ReadResponseStatus ();
86
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000087 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 Vyalov05a55de2015-03-23 21:03:02 +000099 std::string m_device_id;
100 ConnectionFileDescriptor m_conn;
101};
102
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000103} // namespace platform_android
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +0000104} // namespace lldb_private
105
106#endif // liblldb_AdbClient_h_