forked from qt-creator/qt-creator
Android: Introduce removeForwardPortRecipe()
It's going to be used in couple of places. Change-Id: I21c7724da03fb1d294d53fbb372ca4b909a3a842 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
|
||||
#include <solutions/tasking/conditional.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/url.h>
|
||||
@@ -606,6 +608,42 @@ void AndroidRunnerWorker::startDebuggerServer(const QString &packageDir,
|
||||
}
|
||||
}
|
||||
|
||||
ExecutableItem AndroidRunnerWorker::removeForwardPortRecipe(
|
||||
const QString &port, const QString &adbArg, const QString &portType)
|
||||
{
|
||||
const auto onForwardListSetup = [](Process &process) {
|
||||
process.setCommand({AndroidConfig::adbToolPath(), {"forward", "--list"}});
|
||||
};
|
||||
const auto onForwardListDone = [port](const Process &process) {
|
||||
return process.cleanedStdOut().trimmed().contains(port);
|
||||
};
|
||||
|
||||
const auto onForwardRemoveSetup = [this, port](Process &process) {
|
||||
process.setCommand({AndroidConfig::adbToolPath(), {selector(), "--remove", port}});
|
||||
};
|
||||
const auto onForwardRemoveDone = [this](const Process &process) {
|
||||
emit remoteErrorOutput(process.cleanedStdErr().trimmed());
|
||||
return true;
|
||||
};
|
||||
|
||||
const auto onForwardPortSetup = [this, port, adbArg](Process &process) {
|
||||
process.setCommand({AndroidConfig::adbToolPath(), {selector(), port, adbArg}});
|
||||
};
|
||||
const auto onForwardPortDone = [this, port, portType](DoneWith result) {
|
||||
if (result == DoneWith::Success)
|
||||
m_afterFinishAdbCommands.push_back("forward --remove " + port);
|
||||
else
|
||||
emit remoteProcessFinished(Tr::tr("Failed to forward %1 debugging ports.").arg(portType));
|
||||
};
|
||||
|
||||
return Group {
|
||||
If (ProcessTask(onForwardListSetup, onForwardListDone)) >> Then {
|
||||
ProcessTask(onForwardRemoveSetup, onForwardRemoveDone, CallDoneIf::Error)
|
||||
},
|
||||
ProcessTask(onForwardPortSetup, onForwardPortDone)
|
||||
};
|
||||
}
|
||||
|
||||
ExecutableItem AndroidRunnerWorker::pidRecipe()
|
||||
{
|
||||
const Storage<PidUserPair> pidStorage;
|
||||
|
@@ -74,6 +74,8 @@ private:
|
||||
};
|
||||
void onProcessIdChanged(const PidUserPair &pidUser);
|
||||
bool isPreNougat() const { return m_apiLevel > 0 && m_apiLevel <= 23; }
|
||||
Tasking::ExecutableItem removeForwardPortRecipe(const QString &port, const QString &adbArg,
|
||||
const QString &portType);
|
||||
Tasking::ExecutableItem pidRecipe();
|
||||
|
||||
// Create the processes and timer in the worker thread, for correct thread affinity
|
||||
|
Reference in New Issue
Block a user