From 84b7e199ac11e80ad702bb61384747230e02b682 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 25 Aug 2016 16:10:13 +0300 Subject: [PATCH] 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 --- src/plugins/android/androidrunner.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp index 002a8b8c50f..a7e0799a37a 100644 --- a/src/plugins/android/androidrunner.cpp +++ b/src/plugins/android/androidrunner.cpp @@ -241,10 +241,16 @@ static int extractPidFromChunk(const QByteArray &chunk, int from) static int extractPid(const QString &exeName, const QByteArray &psOutput) { - const QByteArray needle = exeName.toUtf8() + '\r'; - const int to = psOutput.indexOf(needle); - if (to == -1) - return -1; + static char psEol[]={'\r', '\n'}; + QByteArray needle = exeName.toUtf8() + psEol[0]; + int to = psOutput.indexOf(needle); + 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); if (from == -1) return -1;