forked from qt-creator/qt-creator
Android: Move pid recipe into a separate function
The task tree runner is going to run more tasks. Change-Id: I342d041134968286a2cf1b20cabe2b4c01ce02b0 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -38,6 +38,7 @@ static const int GdbTempFileMaxCounter = 20;
|
|||||||
}
|
}
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -206,7 +207,7 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
|
|||||||
|
|
||||||
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||||
m_useAppParamsForQmlDebugger = version->qtVersion() >= QVersionNumber(5, 12);
|
m_useAppParamsForQmlDebugger = version->qtVersion() >= QVersionNumber(5, 12);
|
||||||
m_pidRunner.setParent(this); // Move m_pidRunner object together with *this into a separate thread.
|
m_taskTreeRunner.setParent(this); // Move m_taskTreeRunner object together with *this into a separate thread.
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidRunnerWorker::~AndroidRunnerWorker()
|
AndroidRunnerWorker::~AndroidRunnerWorker()
|
||||||
@@ -443,6 +444,7 @@ void AndroidRunnerWorker::asyncStartHelper()
|
|||||||
forceStop();
|
forceStop();
|
||||||
asyncStartLogcat();
|
asyncStartLogcat();
|
||||||
|
|
||||||
|
// 1. For loop
|
||||||
for (const QString &entry : std::as_const(m_beforeStartAdbCommands))
|
for (const QString &entry : std::as_const(m_beforeStartAdbCommands))
|
||||||
runAdb(entry.split(' ', Qt::SkipEmptyParts));
|
runAdb(entry.split(' ', Qt::SkipEmptyParts));
|
||||||
|
|
||||||
@@ -454,6 +456,7 @@ void AndroidRunnerWorker::asyncStartHelper()
|
|||||||
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
|
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
|
||||||
// currently forward to same port on device and host
|
// currently forward to same port on device and host
|
||||||
const QString port = "tcp:" + QString::number(m_qmlServer.port());
|
const QString port = "tcp:" + QString::number(m_qmlServer.port());
|
||||||
|
// 2. removeForwardPort recipe
|
||||||
if (!removeForwardPort(port, port, "QML"))
|
if (!removeForwardPort(port, port, "QML"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -488,6 +491,7 @@ void AndroidRunnerWorker::asyncStartHelper()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString stdErr;
|
QString stdErr;
|
||||||
|
// 3. run adb recipe
|
||||||
const bool startResult = runAdb(args, nullptr, &stdErr);
|
const bool startResult = runAdb(args, nullptr, &stdErr);
|
||||||
if (!startResult) {
|
if (!startResult) {
|
||||||
emit remoteProcessFinished(Tr::tr("Failed to start the activity."));
|
emit remoteProcessFinished(Tr::tr("Failed to start the activity."));
|
||||||
@@ -602,12 +606,8 @@ void AndroidRunnerWorker::startDebuggerServer(const QString &packageDir,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidRunnerWorker::asyncStart()
|
ExecutableItem AndroidRunnerWorker::pidRecipe()
|
||||||
{
|
{
|
||||||
asyncStartHelper();
|
|
||||||
|
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
const Storage<PidUserPair> pidStorage;
|
const Storage<PidUserPair> pidStorage;
|
||||||
|
|
||||||
const FilePath adbPath = AndroidConfig::adbToolPath();
|
const FilePath adbPath = AndroidConfig::adbToolPath();
|
||||||
@@ -650,7 +650,7 @@ void AndroidRunnerWorker::asyncStart()
|
|||||||
return DoneResult::Error;
|
return DoneResult::Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Group root {
|
return Group {
|
||||||
pidStorage,
|
pidStorage,
|
||||||
onGroupSetup([pidStorage] { *pidStorage = {-1, 0}; }),
|
onGroupSetup([pidStorage] { *pidStorage = {-1, 0}; }),
|
||||||
Forever {
|
Forever {
|
||||||
@@ -662,13 +662,18 @@ void AndroidRunnerWorker::asyncStart()
|
|||||||
ProcessTask(onUserSetup, onUserDone, CallDoneIf::Success),
|
ProcessTask(onUserSetup, onUserDone, CallDoneIf::Success),
|
||||||
onGroupDone([pidStorage, this] { onProcessIdChanged(*pidStorage); })
|
onGroupDone([pidStorage, this] { onProcessIdChanged(*pidStorage); })
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
m_pidRunner.start(root);
|
void AndroidRunnerWorker::asyncStart()
|
||||||
|
{
|
||||||
|
asyncStartHelper();
|
||||||
|
|
||||||
|
m_taskTreeRunner.start({pidRecipe()});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidRunnerWorker::asyncStop()
|
void AndroidRunnerWorker::asyncStop()
|
||||||
{
|
{
|
||||||
m_pidRunner.reset();
|
m_taskTreeRunner.reset();
|
||||||
if (m_processPID != -1)
|
if (m_processPID != -1)
|
||||||
forceStop();
|
forceStop();
|
||||||
|
|
||||||
|
@@ -74,6 +74,7 @@ private:
|
|||||||
};
|
};
|
||||||
void onProcessIdChanged(const PidUserPair &pidUser);
|
void onProcessIdChanged(const PidUserPair &pidUser);
|
||||||
bool isPreNougat() const { return m_apiLevel > 0 && m_apiLevel <= 23; }
|
bool isPreNougat() const { return m_apiLevel > 0 && m_apiLevel <= 23; }
|
||||||
|
Tasking::ExecutableItem pidRecipe();
|
||||||
|
|
||||||
// Create the processes and timer in the worker thread, for correct thread affinity
|
// Create the processes and timer in the worker thread, for correct thread affinity
|
||||||
QString m_packageName;
|
QString m_packageName;
|
||||||
@@ -87,7 +88,7 @@ private:
|
|||||||
std::unique_ptr<Utils::Process> m_psIsAlive;
|
std::unique_ptr<Utils::Process> m_psIsAlive;
|
||||||
QByteArray m_stdoutBuffer;
|
QByteArray m_stdoutBuffer;
|
||||||
QByteArray m_stderrBuffer;
|
QByteArray m_stderrBuffer;
|
||||||
Tasking::TaskTreeRunner m_pidRunner;
|
Tasking::TaskTreeRunner m_taskTreeRunner;
|
||||||
bool m_useCppDebugger = false;
|
bool m_useCppDebugger = false;
|
||||||
bool m_useLldb = false; // FIXME: Un-implemented currently.
|
bool m_useLldb = false; // FIXME: Un-implemented currently.
|
||||||
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
|
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
|
||||||
|
Reference in New Issue
Block a user