Try alternative ps for some android devices that don't support ps -A

This commit is contained in:
Baldur Karlsson
2018-03-13 17:31:32 +00:00
parent 34c4ecd1f2
commit f49dfadc9a
+12
View File
@@ -100,6 +100,18 @@ int GetCurrentPID(const std::string &deviceID, const std::string &packageName)
std::string output = trim(pidOutput.strStdout);
size_t space = output.find_first_of("\t ");
// if we didn't get a response, try without the -A as some android devices don't support that
// parameter
if(output.empty() || output.find(packageName) == std::string::npos || space == std::string::npos)
{
pidOutput =
adbExecCommand(deviceID, StringFormat::Fmt("shell ps | grep %s", packageName.c_str()));
output = trim(pidOutput.strStdout);
space = output.find_first_of("\t ");
}
// if we still didn't get a response, sleep and try again next time
if(output.empty() || output.find(packageName) == std::string::npos || space == std::string::npos)
{
Threading::Sleep(200);