From 6f001068d3263ce161ba0dd3b4b5cddbf555d09d Mon Sep 17 00:00:00 2001 From: Oleksiy Vyalov Date: Wed, 25 Mar 2015 17:58:13 +0000 Subject: Use Android device serial number instead of hostname as a target identifier within module cache. http://reviews.llvm.org/D8597 llvm-svn: 233202 --- .../Plugins/Platform/Android/PlatformAndroid.cpp | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp') diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp index 02d283b1a51..e339e03db6d 100644 --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -15,6 +15,7 @@ #include "lldb/Host/HostInfo.h" // Project includes +#include "AdbClient.h" #include "PlatformAndroid.h" #include "PlatformAndroidRemoteGDBServer.h" @@ -171,6 +172,8 @@ PlatformAndroid::GetPluginName() Error PlatformAndroid::ConnectRemote (Args& args) { + m_device_id.clear (); + if (IsHost()) { return Error ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString()); @@ -178,5 +181,24 @@ PlatformAndroid::ConnectRemote (Args& args) if (!m_remote_platform_sp) m_remote_platform_sp = PlatformSP(new PlatformAndroidRemoteGDBServer()); - return PlatformLinux::ConnectRemote (args); + + auto error = PlatformLinux::ConnectRemote (args); + if (error.Success ()) + { + // Fetch the device list from ADB and if only 1 device found then use that device + // TODO: Handle the case when more device is available + AdbClient adb; + error = AdbClient::CreateByDeviceID (nullptr, adb); + if (error.Fail ()) + return error; + + m_device_id = adb.GetDeviceID (); + } + return error; +} + +const char * +PlatformAndroid::GetCacheHostname () +{ + return m_device_id.c_str (); } -- cgit v1.2.3