Android: Fix package name search

Android 7.0 ps doesn't add \r anymore to the EOL.

Task-number: QTCREATORBUG-16782
Change-Id: Iff596ac2c1eafd0c5422cbac5708c8b616c73ecf
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
BogDan Vatra
2016-08-25 16:10:13 +03:00
parent a3739fb14b
commit 84b7e199ac

View File

@@ -241,10 +241,16 @@ static int extractPidFromChunk(const QByteArray &chunk, int from)
static int extractPid(const QString &exeName, const QByteArray &psOutput) static int extractPid(const QString &exeName, const QByteArray &psOutput)
{ {
const QByteArray needle = exeName.toUtf8() + '\r'; static char psEol[]={'\r', '\n'};
const int to = psOutput.indexOf(needle); QByteArray needle = exeName.toUtf8() + psEol[0];
if (to == -1) int to = psOutput.indexOf(needle);
return -1; if (to == -1) {
needle = exeName.toUtf8() + psEol[1];
to = psOutput.indexOf(needle);
if (to == -1)
return -1;
std::swap(psEol[0], psEol[1]);
}
const int from = psOutput.lastIndexOf('\n', to); const int from = psOutput.lastIndexOf('\n', to);
if (from == -1) if (from == -1)
return -1; return -1;