diff options
author | Tamas Berghammer <tberghammer@google.com> | 2015-08-12 11:10:19 +0000 |
---|---|---|
committer | Tamas Berghammer <tberghammer@google.com> | 2015-08-12 11:10:19 +0000 |
commit | 1d0d90b906a5c39910fa37398ef7d84dbf8f4611 (patch) | |
tree | 6eede91cdf52b86ec54fe73403dee8d9f76f7d8b /lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | |
parent | 5451544a172446f1f64edfa4078582d09c54ccf7 (diff) | |
download | bcm5719-llvm-1d0d90b906a5c39910fa37398ef7d84dbf8f4611.tar.gz bcm5719-llvm-1d0d90b906a5c39910fa37398ef7d84dbf8f4611.zip |
Fetch SDK version from PlatformAndroid
The SDK version implies the features supported by a given android
device. This version number will be used in future changes to execute
the right command on the device.
Differential revision: http://reviews.llvm.org/D11935
llvm-svn: 244737
Diffstat (limited to 'lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp')
-rw-r--r-- | lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp index ed749571692..22b7918dbf4 100644 --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Host/StringConvert.h" #include "Utility/UriParser.h" // Project includes @@ -133,7 +134,8 @@ PlatformAndroid::CreateInstance (bool force, const ArchSpec *arch) } PlatformAndroid::PlatformAndroid (bool is_host) : - PlatformLinux(is_host) + PlatformLinux(is_host), + m_sdk_version(0) { } @@ -257,3 +259,46 @@ PlatformAndroid::DownloadModuleSlice (const FileSpec &src_file_spec, return GetFile (src_file_spec, dst_file_spec); } + +Error +PlatformAndroid::DisconnectRemote() +{ + Error error = PlatformLinux::DisconnectRemote(); + if (error.Success()) + { + m_device_id.clear(); + m_sdk_version = 0; + } + return error; +} + +uint32_t +PlatformAndroid::GetSdkVersion() +{ + if (!IsConnected()) + return 0; + + if (m_sdk_version != 0) + return m_sdk_version; + + int status = 0; + std::string version_string; + Error error = RunShellCommand("getprop ro.build.version.sdk", + GetWorkingDirectory(), + &status, + nullptr, + &version_string, + 1); + if (error.Fail() || status != 0 || version_string.empty()) + { + Log* log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM); + if (log) + log->Printf("Get SDK version failed. (status: %d, error: %s, output: %s)", + status, error.AsCString(), version_string.c_str()); + return 0; + } + version_string.erase(version_string.size() - 1); // Remove trailing new line + + m_sdk_version = StringConvert::ToUInt32(version_string.c_str()); + return m_sdk_version; +} |