blob: 783e5804b6d633ce00ac741b6830a4bc901cface [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
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000056private:
57 Error
58 Connect ();
59
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000060 void
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000061 SetDeviceID (const std::string &device_id);
Oleksiy Vyalov6f001062015-03-25 17:58:13 +000062
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000063 Error
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000064 SendMessage (const std::string &packet, const bool reconnect = true);
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +000065
66 Error
67 SendDeviceMessage (const std::string &packet);
68
69 Error
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000070 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 Vyalov05a55de2015-03-23 21:03:02 +000080
81 Error
82 ReadResponseStatus ();
83
Oleksiy Vyalov09e9079d2015-05-18 23:44:06 +000084 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 Vyalov05a55de2015-03-23 21:03:02 +000096 std::string m_device_id;
97 ConnectionFileDescriptor m_conn;
98};
99
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000100} // namespace platform_android
Oleksiy Vyalov05a55de2015-03-23 21:03:02 +0000101} // namespace lldb_private
102
103#endif // liblldb_AdbClient_h_