Commit c89c62c6 authored by Daniel Teske's avatar Daniel Teske
Browse files

Android: Make AndroidRunner::stop() work



There are two different ways we used to stop a application:
am force-stop $packageName or kill -9 applicationPid. As far as I
remember that's because on some devices some one of them didn't work.
The code wasn't consistently using both though. Fix that by making it
one function, which uses both and use that one consistently.

Task-number: QTCREATORBUG-10557
Change-Id: Ib09a51e2bddae8d28a5d234e792906cc03606fda
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent fc6386be
...@@ -166,12 +166,11 @@ void AndroidRunner::checkPID() ...@@ -166,12 +166,11 @@ void AndroidRunner::checkPID()
void AndroidRunner::forceStop() void AndroidRunner::forceStop()
{ {
QProcess proc; QProcess proc;
proc.start(m_adb, selector() << _("shell") << _("am") << _("force-stop")); proc.start(m_adb, selector() << _("shell") << _("am") << _("force-stop")
<< m_packageName);
proc.waitForFinished(); proc.waitForFinished();
}
void AndroidRunner::killPID() // try killing it via kill -9
{
const QByteArray out = runPs(); const QByteArray out = runPs();
int from = 0; int from = 0;
while (1) { while (1) {
...@@ -198,7 +197,6 @@ void AndroidRunner::asyncStart() ...@@ -198,7 +197,6 @@ void AndroidRunner::asyncStart()
{ {
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
forceStop(); forceStop();
killPID();
if (m_useCppDebugger) { if (m_useCppDebugger) {
// Remove pong file. // Remove pong file.
...@@ -345,7 +343,7 @@ void AndroidRunner::stop() ...@@ -345,7 +343,7 @@ void AndroidRunner::stop()
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
m_checkPIDTimer.stop(); m_checkPIDTimer.stop();
if (m_processPID != -1) { if (m_processPID != -1) {
killPID(); forceStop();
emit remoteProcessFinished(tr("\n\n'%1' terminated.").arg(m_packageName)); emit remoteProcessFinished(tr("\n\n'%1' terminated.").arg(m_packageName));
} }
//QObject::disconnect(&m_adbLogcatProcess, 0, this, 0); //QObject::disconnect(&m_adbLogcatProcess, 0, this, 0);
......
...@@ -71,7 +71,6 @@ signals: ...@@ -71,7 +71,6 @@ signals:
void remoteErrorOutput(const QByteArray &output); void remoteErrorOutput(const QByteArray &output);
private slots: private slots:
void killPID();
void checkPID(); void checkPID();
void logcatReadStandardError(); void logcatReadStandardError();
void logcatReadStandardOutput(); void logcatReadStandardOutput();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment