Skip to content

Commit

Permalink
Fix Android-SDK detection on API 10 device
Browse files Browse the repository at this point in the history
Run the getprop command with AdbClient::Shell instead of
Platform::RunShellCommand because getting the output from getprop
with Platform::RunShellCommand have some (currently unknown) issues.

llvm-svn: 249014
  • Loading branch information
Tamas Berghammer committed Oct 1, 2015
1 parent 76011b6 commit 3e8947b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,19 @@ PlatformAndroid::GetSdkVersion()
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())
AdbClient adb(m_device_id);
Error error = adb.Shell("getprop ro.build.version.sdk", 5000 /* ms */, &version_string);
version_string = llvm::StringRef(version_string).trim().str();

if (error.Fail() || 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());
log->Printf("Get SDK version failed. (error: %s, output: %s)",
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;
Expand Down

0 comments on commit 3e8947b

Please sign in to comment.