iOS: Add a "handler" property for the tool that is used for device ops

To the IosDevice. So other parts of the code know if the device can (and
should) be handled via devicectl instead of iostool.

Change-Id: I700bd1528fad505c3f4b6442d73e24b09ceba68a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Eike Ziller
2024-01-12 11:40:20 +01:00
parent b2eac9acf8
commit 1a29b9e36c
2 changed files with 28 additions and 9 deletions

View File

@@ -85,6 +85,8 @@ const char vOff[] = "*off*";
const char vDevelopment[] = "Development"; const char vDevelopment[] = "Development";
const char vYes[] = "YES"; const char vYes[] = "YES";
const char kHandler[] = "Handler";
class IosDeviceInfoWidget : public IDeviceWidget class IosDeviceInfoWidget : public IDeviceWidget
{ {
public: public:
@@ -145,6 +147,7 @@ void IosDevice::fromMap(const Store &map)
const Store vMap = storeFromVariant(map.value(Constants::EXTRA_INFO_KEY)); const Store vMap = storeFromVariant(map.value(Constants::EXTRA_INFO_KEY));
for (auto i = vMap.cbegin(), end = vMap.cend(); i != end; ++i) for (auto i = vMap.cbegin(), end = vMap.cend(); i != end; ++i)
m_extraInfo.insert(stringFromKey(i.key()), i.value().toString()); m_extraInfo.insert(stringFromKey(i.key()), i.value().toString());
m_handler = Handler(map.value(kHandler).toInt());
} }
Store IosDevice::toMap() const Store IosDevice::toMap() const
@@ -154,6 +157,7 @@ Store IosDevice::toMap() const
for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i) for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i)
vMap.insert(keyFromString(i.key()), i.value()); vMap.insert(keyFromString(i.key()), i.value());
res.insert(Constants::EXTRA_INFO_KEY, variantFromStore(vMap)); res.insert(Constants::EXTRA_INFO_KEY, variantFromStore(vMap));
res.insert(kHandler, int(m_handler));
return res; return res;
} }
@@ -195,6 +199,11 @@ Utils::Port IosDevice::nextPort() const
return Utils::Port(m_lastPort); return Utils::Port(m_lastPort);
} }
IosDevice::Handler IosDevice::handler() const
{
return m_handler;
}
// IosDeviceManager // IosDeviceManager
IosDeviceManager::TranslationMap IosDeviceManager::translationMap() IosDeviceManager::TranslationMap IosDeviceManager::translationMap()
@@ -293,7 +302,7 @@ void IosDeviceManager::updateInfo(const QString &devId)
info[kCpuArchitecture] info[kCpuArchitecture]
= device["hardwareProperties"]["cpuType"]["name"].toString(); = device["hardwareProperties"]["cpuType"]["name"].toString();
info[kUniqueDeviceId] = udid; info[kUniqueDeviceId] = udid;
deviceInfo(nullptr, devId, info); deviceInfo(devId, IosDevice::Handler::DeviceCtl, info);
return DoneResult::Success; return DoneResult::Success;
} }
} }
@@ -305,10 +314,13 @@ void IosDeviceManager::updateInfo(const QString &devId)
const auto infoFromIosTool = IosToolTask([this, devId](IosToolRunner &runner) { const auto infoFromIosTool = IosToolTask([this, devId](IosToolRunner &runner) {
runner.setDeviceType(IosDeviceType::IosDevice); runner.setDeviceType(IosDeviceType::IosDevice);
runner.setStartHandler([this, devId](IosToolHandler *handler) { runner.setStartHandler([this, devId](IosToolHandler *handler) {
connect(handler, connect(
handler,
&IosToolHandler::deviceInfo, &IosToolHandler::deviceInfo,
this, this,
&IosDeviceManager::deviceInfo, [this](IosToolHandler *, const QString &uid, const Ios::IosToolHandler::Dict &info) {
deviceInfo(uid, IosDevice::Handler::IosTool, info);
},
Qt::QueuedConnection); Qt::QueuedConnection);
handler->requestDeviceInfo(devId); handler->requestDeviceInfo(devId);
}); });
@@ -320,7 +332,8 @@ void IosDeviceManager::updateInfo(const QString &devId)
task->start(); task->start();
} }
void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid, void IosDeviceManager::deviceInfo(const QString &uid,
IosDevice::Handler handler,
const Ios::IosToolHandler::Dict &info) const Ios::IosToolHandler::Dict &info)
{ {
DeviceManager *devManager = DeviceManager::instance(); DeviceManager *devManager = DeviceManager::instance();
@@ -332,7 +345,7 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
IosDevice *newDev = nullptr; IosDevice *newDev = nullptr;
if (!dev.isNull() && dev->type() == devType) { if (!dev.isNull() && dev->type() == devType) {
auto iosDev = static_cast<const IosDevice *>(dev.data()); auto iosDev = static_cast<const IosDevice *>(dev.data());
if (iosDev->m_extraInfo == info) { if (iosDev->m_handler == handler && iosDev->m_extraInfo == info) {
skipUpdate = true; skipUpdate = true;
newDev = const_cast<IosDevice *>(iosDev); newDev = const_cast<IosDevice *>(iosDev);
} else { } else {
@@ -346,6 +359,7 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
if (info.contains(kDeviceName)) if (info.contains(kDeviceName))
newDev->settings()->displayName.setValue(info.value(kDeviceName)); newDev->settings()->displayName.setValue(info.value(kDeviceName));
newDev->m_extraInfo = info; newDev->m_extraInfo = info;
newDev->m_handler = handler;
qCDebug(detectLog) << "updated info of ios device " << uid; qCDebug(detectLog) << "updated info of ios device " << uid;
dev = IDevice::ConstPtr(newDev); dev = IDevice::ConstPtr(newDev);
devManager->addDevice(dev); devManager->addDevice(dev);

View File

@@ -23,6 +23,8 @@ public:
using ConstPtr = QSharedPointer<const IosDevice>; using ConstPtr = QSharedPointer<const IosDevice>;
using Ptr = QSharedPointer<IosDevice>; using Ptr = QSharedPointer<IosDevice>;
enum class Handler { IosTool, DeviceCtl };
ProjectExplorer::IDevice::DeviceInfo deviceInformation() const override; ProjectExplorer::IDevice::DeviceInfo deviceInformation() const override;
ProjectExplorer::IDeviceWidget *createWidget() override; ProjectExplorer::IDeviceWidget *createWidget() override;
@@ -32,6 +34,7 @@ public:
QString osVersion() const; QString osVersion() const;
QString cpuArchitecture() const; QString cpuArchitecture() const;
Utils::Port nextPort() const; Utils::Port nextPort() const;
Handler handler() const;
static QString name(); static QString name();
@@ -48,6 +51,7 @@ protected:
IosDevice(CtorHelper); IosDevice(CtorHelper);
Dict m_extraInfo; Dict m_extraInfo;
Handler m_handler = Handler::IosTool;
bool m_ignoreDevice = false; bool m_ignoreDevice = false;
mutable quint16 m_lastPort; mutable quint16 m_lastPort;
}; };
@@ -73,7 +77,8 @@ public:
void deviceDisconnected(const QString &uid); void deviceDisconnected(const QString &uid);
friend class IosConfigurations; friend class IosConfigurations;
void updateInfo(const QString &devId); void updateInfo(const QString &devId);
void deviceInfo(Ios::IosToolHandler *gatherer, const QString &deviceId, void deviceInfo(const QString &deviceId,
IosDevice::Handler handler,
const Ios::IosToolHandler::Dict &info); const Ios::IosToolHandler::Dict &info);
void monitorAvailableDevices(); void monitorAvailableDevices();