diff options
author | Oleksiy Vyalov <ovyalov@google.com> | 2015-03-25 17:58:13 +0000 |
---|---|---|
committer | Oleksiy Vyalov <ovyalov@google.com> | 2015-03-25 17:58:13 +0000 |
commit | 6f001068d3263ce161ba0dd3b4b5cddbf555d09d (patch) | |
tree | f9516e27525d3a9633f149f1a985ac32d52b56f5 /lldb/source/Plugins/Platform/Android/AdbClient.cpp | |
parent | ff2a64cf1bedc3196f949848fcf8773b95484c60 (diff) | |
download | bcm5719-llvm-6f001068d3263ce161ba0dd3b4b5cddbf555d09d.tar.gz bcm5719-llvm-6f001068d3263ce161ba0dd3b4b5cddbf555d09d.zip |
Use Android device serial number instead of hostname as a target identifier within module cache.
http://reviews.llvm.org/D8597
llvm-svn: 233202
Diffstat (limited to 'lldb/source/Plugins/Platform/Android/AdbClient.cpp')
-rw-r--r-- | lldb/source/Plugins/Platform/Android/AdbClient.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Platform/Android/AdbClient.cpp b/lldb/source/Plugins/Platform/Android/AdbClient.cpp index eb094a17439..d3d5878380b 100644 --- a/lldb/source/Plugins/Platform/Android/AdbClient.cpp +++ b/lldb/source/Plugins/Platform/Android/AdbClient.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // Other libraries and framework includes -#include "lldb/Host/ConnectionFileDescriptor.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/STLExtras.h" @@ -16,6 +15,7 @@ // Project includes #include "AdbClient.h" +#include <algorithm> #include <sstream> using namespace lldb; @@ -29,6 +29,32 @@ const char * kFAIL = "FAIL"; } // namespace +Error +AdbClient::CreateByDeviceID (const char* device_id, AdbClient &adb) +{ + DeviceIDList connect_devices; + auto error = adb.GetDevices (connect_devices); + if (error.Fail ()) + return error; + + if (device_id) + { + auto find_it = std::find(connect_devices.begin (), connect_devices.end (), device_id); + if (find_it == connect_devices.end ()) + return Error ("Device \"%s\" not found", device_id); + + adb.SetDeviceID (*find_it); + } + else + { + if (connect_devices.size () != 1) + return Error ("Expected a single connected device, got instead %zu", connect_devices.size ()); + + adb.SetDeviceID (connect_devices.front ()); + } + return error; +} + AdbClient::AdbClient (const std::string &device_id) : m_device_id (device_id) { @@ -40,6 +66,12 @@ AdbClient::SetDeviceID (const std::string& device_id) m_device_id = device_id; } +const std::string& +AdbClient::GetDeviceID() const +{ + return m_device_id; +} + Error AdbClient::Connect () { |