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: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
Daniel Teske
2013-10-30 15:39:05 +01:00
parent fc6386be80
commit c89c62c62f
2 changed files with 4 additions and 7 deletions

View File

@@ -166,12 +166,11 @@ void AndroidRunner::checkPID()
void AndroidRunner::forceStop()
{
QProcess proc;
proc.start(m_adb, selector() << _("shell") << _("am") << _("force-stop"));
proc.start(m_adb, selector() << _("shell") << _("am") << _("force-stop")
<< m_packageName);
proc.waitForFinished();
}
void AndroidRunner::killPID()
{
// try killing it via kill -9
const QByteArray out = runPs();
int from = 0;
while (1) {
@@ -198,7 +197,6 @@ void AndroidRunner::asyncStart()
{
QMutexLocker locker(&m_mutex);
forceStop();
killPID();
if (m_useCppDebugger) {
// Remove pong file.
@@ -345,7 +343,7 @@ void AndroidRunner::stop()
QMutexLocker locker(&m_mutex);
m_checkPIDTimer.stop();
if (m_processPID != -1) {
killPID();
forceStop();
emit remoteProcessFinished(tr("\n\n'%1' terminated.").arg(m_packageName));
}
//QObject::disconnect(&m_adbLogcatProcess, 0, this, 0);