summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2015-09-23 09:25:50 +0200
committerhjk <hjk@theqtcompany.com>2015-09-23 14:53:22 +0000
commitb6e52b0c375c34e17e643faafef4f52276389a0d (patch)
tree19a032df0dad3104ee986ed99393b366b8fc6a4c
parent11cafd198d0abf9e0cb3aead4d000c72f9c86c94 (diff)
downloadqt-creator-b6e52b0c375c34e17e643faafef4f52276389a0d.tar.gz
Android: Fix debugger startup with recent Android SDK
Android SDK Tools 24.x ship an adb that requires in the 'adb shell' command an additional level of quotes for parameters with spaces compared to previous versions. That broke the passing of the gdbserver start command and consequently debugger startup. Task-number: QTCREATORBUG-15032 Change-Id: I442355821641d4c6a632b50d1065c442736711aa Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
-rw-r--r--src/plugins/android/androidrunner.cpp28
-rw-r--r--src/plugins/android/androidrunner.h2
2 files changed, 27 insertions, 3 deletions
diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp
index 59d3be60d2..18f3f8421b 100644
--- a/src/plugins/android/androidrunner.cpp
+++ b/src/plugins/android/androidrunner.cpp
@@ -176,7 +176,6 @@ AndroidRunner::AndroidRunner(QObject *parent,
m_gdbserverPath = packageDir + _("/lib/gdbserver");
- m_gdbserverCommand = m_gdbserverPath + _(" --multi +") + m_gdbserverSocket;
// Detect busybox, as we need to pass -w to ps to get wide output.
QProcess psProc;
psProc.start(m_adb, selector() << _("shell") << _("readlink") << _("$(which ps)"));
@@ -371,7 +370,10 @@ void AndroidRunner::asyncStart()
args << _("-e") << _("ping_file") << m_pingFile;
args << _("-e") << _("pong_file") << m_pongFile;
}
- args << _("-e") << _("gdbserver_command") << m_gdbserverCommand;
+
+ QString gdbserverCommand = QString::fromLatin1(adbShellAmNeedsQuotes() ? "\"%1 --multi +%2\"" : "%1 --multi +%2")
+ .arg(m_gdbserverPath).arg(m_gdbserverSocket);
+ args << _("-e") << _("gdbserver_command") << gdbserverCommand;
args << _("-e") << _("gdbserver_socket") << m_gdbserverSocket;
if (m_handShakeMethod == SocketHandShake) {
@@ -494,6 +496,28 @@ void AndroidRunner::asyncStart()
QMetaObject::invokeMethod(&m_checkPIDTimer, "start");
}
+bool AndroidRunner::adbShellAmNeedsQuotes()
+{
+ // Between Android SDK Tools version 24.3.1 and 24.3.4 the quoting
+ // needs for the 'adb shell am start ...' parameters changed.
+ // Run a test to find out on what side of the fence we live.
+ // The command will fail with a complaint about the "--dummy"
+ // option on newer SDKs, and with "No intent supplied" on older ones.
+ // In case the test itself fails assume a new SDK.
+ QProcess adb;
+ adb.start(m_adb, selector() << _("shell") << _("am") << _("start")
+ << _("-e") << _("dummy") <<_("dummy --dummy"));
+ if (!adb.waitForStarted())
+ return true;
+
+ if (!adb.waitForFinished(10000))
+ return true;
+
+ QByteArray output = adb.readAllStandardError() + adb.readAllStandardOutput();
+ bool oldSdk = output.contains("Error: No intent supplied");
+ return !oldSdk;
+}
+
void AndroidRunner::handleRemoteDebuggerRunning()
{
if (m_useCppDebugger) {
diff --git a/src/plugins/android/androidrunner.h b/src/plugins/android/androidrunner.h
index 8bf90f4e8a..dac292e8b5 100644
--- a/src/plugins/android/androidrunner.h
+++ b/src/plugins/android/androidrunner.h
@@ -89,6 +89,7 @@ private:
QByteArray runPs();
void findPs();
void logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError);
+ bool adbShellAmNeedsQuotes();
private:
QProcess m_adbLogcatProcess;
@@ -111,7 +112,6 @@ private:
QString m_pingFile;
QString m_pongFile;
QString m_gdbserverPath;
- QString m_gdbserverCommand;
QString m_gdbserverSocket;
QString m_localLibs;
QString m_localJars;