forked from qt-creator/qt-creator
ProjectExplorer: Add IDevice::portsGatheringRecipe()
It's going to replace portsGatheringMethod(). Using recipe is more general and it enables many process runs or using different task types, e.g. NetworkQueryTask. Change-Id: Ic330a41cf3b5268e0f763b1b7584dbe1d689671e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <solutions/tasking/conditional.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/guard.h>
|
||||
#include <utils/port.h>
|
||||
@@ -625,6 +627,34 @@ DeviceProcessSignalOperation::Ptr AndroidDevice::signalOperation() const
|
||||
return DeviceProcessSignalOperation::Ptr(new AndroidSignalOperation());
|
||||
}
|
||||
|
||||
ExecutableItem AndroidDevice::portsGatheringRecipe(const Storage<PortsOutputData> &output) const
|
||||
{
|
||||
const Storage<QString> serialNumberStorage;
|
||||
const Storage<PortsInputData> input;
|
||||
|
||||
const auto hasSerialNumber = [this, serialNumberStorage] {
|
||||
if (machineType() == Hardware)
|
||||
*serialNumberStorage = extraData(Constants::AndroidSerialNumber).toString();
|
||||
return machineType() == Hardware;
|
||||
};
|
||||
|
||||
const auto onSerialNumberSetup = [this, input, serialNumberStorage] {
|
||||
const CommandLine cmd{AndroidConfig::adbToolPath(),
|
||||
{adbSelector(*serialNumberStorage), "shell" , "netstat", "-a", "-n" }};
|
||||
*input = {freePorts(), cmd};
|
||||
};
|
||||
|
||||
return Group {
|
||||
serialNumberStorage,
|
||||
input,
|
||||
If (!Sync(hasSerialNumber)) >> Then {
|
||||
serialNumberRecipe(avdName(), serialNumberStorage),
|
||||
},
|
||||
Sync(onSerialNumberSetup),
|
||||
portsFromProcessRecipe(input, output)
|
||||
};
|
||||
}
|
||||
|
||||
PortsGatheringMethod AndroidDevice::portsGatheringMethod() const
|
||||
{
|
||||
return {
|
||||
|
@@ -58,6 +58,8 @@ private:
|
||||
ProjectExplorer::IDeviceWidget *createWidget() override;
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
QUrl toolControlChannel(const ControlChannelHint &) const override;
|
||||
Tasking::ExecutableItem portsGatheringRecipe(
|
||||
const Tasking::Storage<Utils::PortsOutputData> &output) const override;
|
||||
ProjectExplorer::PortsGatheringMethod portsGatheringMethod() const override;
|
||||
|
||||
QSettings *avdSettings() const;
|
||||
|
@@ -83,6 +83,7 @@
|
||||
* Creates an identical copy of a device object.
|
||||
*/
|
||||
|
||||
using namespace Tasking;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -439,6 +440,24 @@ const QList<IDevice::DeviceAction> IDevice::deviceActions() const
|
||||
return d->deviceActions;
|
||||
}
|
||||
|
||||
ExecutableItem IDevice::portsGatheringRecipe(const Storage<PortsOutputData> &output) const
|
||||
{
|
||||
const Storage<PortsInputData> input;
|
||||
|
||||
const auto onSetup = [this, input] {
|
||||
const CommandLine cmd = filePath("/proc/net").isReadableDir()
|
||||
? CommandLine{filePath("/bin/sh"), {"-c", "cat /proc/net/tcp*"}}
|
||||
: CommandLine{filePath("netstat"), {"-a", "-n"}};
|
||||
*input = {freePorts(), cmd};
|
||||
};
|
||||
|
||||
return Group {
|
||||
input,
|
||||
onGroupSetup(onSetup),
|
||||
portsFromProcessRecipe(input, output)
|
||||
};
|
||||
}
|
||||
|
||||
PortsGatheringMethod IDevice::portsGatheringMethod() const
|
||||
{
|
||||
return {[this](QAbstractSocket::NetworkLayerProtocol protocol) -> CommandLine {
|
||||
@@ -757,8 +776,6 @@ void DeviceProcessSignalOperation::setDebuggerCommand(const FilePath &cmd)
|
||||
|
||||
DeviceProcessSignalOperation::DeviceProcessSignalOperation() = default;
|
||||
|
||||
using namespace Tasking;
|
||||
|
||||
void DeviceProcessKiller::start()
|
||||
{
|
||||
m_signalOperation.reset();
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/id.h>
|
||||
#include <utils/portlist.h>
|
||||
#include <utils/store.h>
|
||||
|
||||
#include <QAbstractSocket>
|
||||
@@ -140,6 +141,8 @@ public:
|
||||
void addDeviceAction(const DeviceAction &deviceAction);
|
||||
const QList<DeviceAction> deviceActions() const;
|
||||
|
||||
virtual Tasking::ExecutableItem portsGatheringRecipe(
|
||||
const Tasking::Storage<Utils::PortsOutputData> &output) const;
|
||||
virtual PortsGatheringMethod portsGatheringMethod() const;
|
||||
virtual bool canCreateProcessModel() const { return false; }
|
||||
virtual bool hasDeviceTester() const { return false; }
|
||||
|
Reference in New Issue
Block a user