aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamas Berghammer <tberghammer@google.com>2015-08-12 11:10:19 +0000
committerTamas Berghammer <tberghammer@google.com>2015-08-12 11:10:19 +0000
commit48905c196f30a0e655ce7eee86f77d9752d9c8e9 (patch)
tree9d8d45515d8bcb1dab1a99aff814427314905c0b
parentfba5f26992274c3638718765cfaf125bcf2a6f1d (diff)
downloadlldb-48905c196f30a0e655ce7eee86f77d9752d9c8e9.tar.gz
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@244737 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroid.cpp47
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroid.h8
2 files changed, 54 insertions, 1 deletions
diff --git a/source/Plugins/Platform/Android/PlatformAndroid.cpp b/source/Plugins/Platform/Android/PlatformAndroid.cpp
index ed7495716..22b7918db 100644
--- a/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/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;
+}
diff --git a/source/Plugins/Platform/Android/PlatformAndroid.h b/source/Plugins/Platform/Android/PlatformAndroid.h
index b02a1b5b5..be43fff47 100644
--- a/source/Plugins/Platform/Android/PlatformAndroid.h
+++ b/source/Plugins/Platform/Android/PlatformAndroid.h
@@ -73,6 +73,12 @@ namespace platform_android {
const FileSpec& destination,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX) override;
+
+ uint32_t
+ GetSdkVersion();
+
+ Error
+ DisconnectRemote () override;
protected:
const char *
@@ -86,6 +92,8 @@ namespace platform_android {
private:
std::string m_device_id;
+ uint32_t m_sdk_version;
+
DISALLOW_COPY_AND_ASSIGN (PlatformAndroid);
};