diff options
Diffstat (limited to 'source/Plugins/Platform/Android/AdbClient.h')
-rw-r--r-- | source/Plugins/Platform/Android/AdbClient.h | 82 |
1 files changed, 63 insertions, 19 deletions
diff --git a/source/Plugins/Platform/Android/AdbClient.h b/source/Plugins/Platform/Android/AdbClient.h index 4ec411d1411d..37973bbdccf8 100644 --- a/source/Plugins/Platform/Android/AdbClient.h +++ b/source/Plugins/Platform/Android/AdbClient.h @@ -14,7 +14,9 @@ // C++ Includes +#include <functional> #include <list> +#include <memory> #include <string> #include <vector> @@ -22,7 +24,6 @@ // Project includes #include "lldb/Core/Error.h" -#include "lldb/Host/ConnectionFileDescriptor.h" namespace lldb_private { @@ -41,12 +42,63 @@ public: using DeviceIDList = std::list<std::string>; + class SyncService + { + friend class AdbClient; + + public: + ~SyncService (); + + Error + PullFile (const FileSpec &remote_file, const FileSpec &local_file); + + Error + PushFile (const FileSpec &local_file, const FileSpec &remote_file); + + Error + Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime); + + bool + IsConnected () const; + + private: + explicit SyncService (std::unique_ptr<Connection> &&conn); + + Error + SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data); + + Error + ReadSyncHeader (std::string &response_id, uint32_t &data_len); + + Error + PullFileChunk (std::vector<char> &buffer, bool &eof); + + Error + ReadAllBytes (void *buffer, size_t size); + + Error + internalPullFile (const FileSpec &remote_file, const FileSpec &local_file); + + Error + internalPushFile (const FileSpec &local_file, const FileSpec &remote_file); + + Error + internalStat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime); + + Error + executeCommand (const std::function<Error()> &cmd); + + std::unique_ptr<Connection> m_conn; + }; + static Error CreateByDeviceID(const std::string &device_id, AdbClient &adb); - AdbClient () = default; + AdbClient (); explicit AdbClient (const std::string &device_id); + ~AdbClient(); + const std::string& GetDeviceID() const; @@ -65,16 +117,16 @@ public: DeletePortForwarding (const uint16_t local_port); Error - PullFile (const FileSpec &remote_file, const FileSpec &local_file); + Shell (const char* command, uint32_t timeout_ms, std::string* output); Error - PushFile (const FileSpec &local_file, const FileSpec &remote_file); + ShellToFile(const char *command, uint32_t timeout_ms, const FileSpec &output_file_spec); - Error - Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime); + std::unique_ptr<SyncService> + GetSyncService (Error &error); Error - Shell (const char* command, uint32_t timeout_ms, std::string* output); + SwitchDeviceTransport (); private: Error @@ -90,12 +142,6 @@ private: SendDeviceMessage (const std::string &packet); Error - SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data); - - Error - ReadSyncHeader (std::string &response_id, uint32_t &data_len); - - Error ReadMessage (std::vector<char> &message); Error @@ -108,25 +154,23 @@ private: ReadResponseStatus (); Error - SwitchDeviceTransport (); - - Error Sync (); Error StartSync (); Error - PullFileChunk (std::vector<char> &buffer, bool &eof); + internalShell(const char *command, uint32_t timeout_ms, std::vector<char> &output_buf); Error - ReadAllBytes (void *buffer, size_t size); + ReadAllBytes(void *buffer, size_t size); std::string m_device_id; - ConnectionFileDescriptor m_conn; + std::unique_ptr<Connection> m_conn; }; } // namespace platform_android } // namespace lldb_private #endif // liblldb_AdbClient_h_ + |