tberghammer created this revision. tberghammer added a reviewer: ovyalov. tberghammer added a subscriber: lldb-commits. Herald added subscribers: srhines, danalbert, tberghammer.
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. http://reviews.llvm.org/D11935 Files: source/Plugins/Platform/Android/PlatformAndroid.cpp source/Plugins/Platform/Android/PlatformAndroid.h Index: source/Plugins/Platform/Android/PlatformAndroid.h =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.h +++ source/Plugins/Platform/Android/PlatformAndroid.h @@ -73,6 +73,12 @@ 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 @@ private: std::string m_device_id; + uint32_t m_sdk_version; + DISALLOW_COPY_AND_ASSIGN (PlatformAndroid); }; Index: source/Plugins/Platform/Android/PlatformAndroid.cpp =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.cpp +++ source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -133,7 +133,8 @@ } PlatformAndroid::PlatformAndroid (bool is_host) : - PlatformLinux(is_host) + PlatformLinux(is_host), + m_sdk_version(0) { } @@ -257,3 +258,35 @@ 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; + + std::string version_string; + RunShellCommand("getprop ro.build.version.sdk", + GetWorkingDirectory(), + nullptr, + nullptr, + &version_string, + 1); + m_sdk_version = ::atoi(version_string.c_str()); + return m_sdk_version; +}
Index: source/Plugins/Platform/Android/PlatformAndroid.h =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.h +++ source/Plugins/Platform/Android/PlatformAndroid.h @@ -73,6 +73,12 @@ 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 @@ private: std::string m_device_id; + uint32_t m_sdk_version; + DISALLOW_COPY_AND_ASSIGN (PlatformAndroid); }; Index: source/Plugins/Platform/Android/PlatformAndroid.cpp =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.cpp +++ source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -133,7 +133,8 @@ } PlatformAndroid::PlatformAndroid (bool is_host) : - PlatformLinux(is_host) + PlatformLinux(is_host), + m_sdk_version(0) { } @@ -257,3 +258,35 @@ 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; + + std::string version_string; + RunShellCommand("getprop ro.build.version.sdk", + GetWorkingDirectory(), + nullptr, + nullptr, + &version_string, + 1); + m_sdk_version = ::atoi(version_string.c_str()); + return m_sdk_version; +}
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits